In org-mode org-capture templates, what is the way to insert current time timestamp?

I've tried %U like so:

     ("k" "Capture an item and schedule it for tomorrow" entry
      (file+headline "today.org" "_tomorrow")
      "* TODO %^{Task Title} %^G
Added: %U @ %a" :immediate-finish t))))

but the %U shortcode always produces 00:00 time and the date is the same as the agenda view date at which the point is located at the time the org-capture is invoked.

By the way, I'd also like some suggestions on how to produce a "tomorrow" timestamp in the template, but that is probably a topic for another question.

  • What Emacs and Org versions do you have? Your code works for me as expected.
    – erikstokes
    Commented Jul 4, 2016 at 22:18
  • Emacs, Org-mode version 8.2.10. Did you invoke org-capture from agenda view? Commented Jul 5, 2016 at 5:16
  • I invoked org-capture from the agenda view and your code worked as expected: %U had been replaced by inactive time stamp with current date and time.
    – artscan
    Commented Jul 5, 2016 at 10:17
  • OK, %U worked for me too, but only in the TODO agenda view. In the week or day agenda views the time gets set to 00:00 and the date gets copied from the selected agenda date, not the current time. Is that a bug or a feature? Commented Jul 5, 2016 at 20:26
  • or maybe there is some variable responsible for this behavior? Commented Jul 5, 2016 at 20:52

1 Answer 1


According the help for org-agenda-capture (bound to k in agenda views)

Call ‘org-capture’ with the date at point. With a ‘C-1’ prefix, use the HH:MM value at point (if any) or the current HH:MM time.

It works correctly if you position the cursor on a line that has a time. Otherwise the time seems to always get set to "00:00". The function responsible for getting the time is org-get-cursor-date. This function claims:

Return the date at cursor in as a time. This works in the calendar and in the agenda, anywhere else it just returns the current time. If WITH-TIME is non-nil, returns the time of the event at point (in the agenda) or the current time of the day.

Everywhere except in on a line in an agenda view that doesn't have time, the function behaves as advertised. But if it doesn't find some kind of a timestamp, it defaults the current day at midnight. The relevent piece of code is

(setq date (calendar-gregorian-from-absolute day)
        defd (encode-time 0 (or mod 0) (or hod 0)
                  (nth 1 date) (nth 0 date) (nth 2 date)))

mod and hod are the minute and hour, but aren't getting set and thus default to 0.

This seems to contradict the stated intent of the function and is likely a bug rather than a feature.

  • Maybe it is called org-agenda-capture not org-capture-agenda?
    – artscan
    Commented Jul 5, 2016 at 23:33
  • @artscan Yep. Edited.
    – erikstokes
    Commented Jul 5, 2016 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.