48

Is there a simple way to insert the current time (like TIME: [2012-07-02 Mon 16:44]) in the org-mode? In the manual there is a lot of stuff (clocks, deadlines, schedules), but most of them require entering the time manually.

Ivan Oseledets
  • 2,270
  • 4
  • 23
  • 28

6 Answers6

65

C-u C-c . will insert a timestamp at point, though Org will still prompt you for a time (with the default being the current time).

More: "Creating timestamps" in the Org Mode manual.

Gal
  • 5,338
  • 5
  • 33
  • 55
Jon Gauthier
  • 25,202
  • 6
  • 63
  • 69
  • 2
    If somehow key binding doesn't work you need to `M-x` `org-time-stamp` – Sebastian Apr 11 '16 at 18:51
  • 14
    Yes, I did see that in the manual. But why there's no respective M-x command for the `C-u C-c . ` shortcut. The `M-x org-time-stamp` only inserts the date without time to the current cursor. How about current date with time command? – dezhi Jan 01 '17 at 11:23
  • 5
    Explanation of "prefix argument": The [Org Manual](https://orgmode.org/manual/Creating-Timestamps.html#Creating-Timestamps) says regarding the `C-c .` shortcut to insert a date: "With a prefix argument, it also adds the current time." By this the manual means what [Jon Gauthier](https://stackoverflow.com/users/176075/jon-gauthier) said: type `C-u C-c .` (- - ). The prefix argument is `C-u` (pressing the and keys at the same time once before the rest of your command sequence). – baltakatei Jun 29 '20 at 12:23
  • Can time inserted in between `[]` instead of `<>`? – alper Dec 04 '21 at 19:50
  • 1
    @alper yup, `c-c !` – joshpetit Feb 09 '23 at 15:16
29

In my installation, which is org-mode version 9, the following enters the current date and time without prompting anything

C-u C-u C-c .
anachronic
  • 390
  • 3
  • 4
9
C-u C-c !

inserts an inactive timestamp with the current time such as:

[2018-05-08 Tue 00:30]
Gokul D
  • 91
  • 1
  • 2
5

In emacs-lisp, you could use

(org-insert-time-stamp (current-time) t)

With default settings, it will generate a time stamp on the format

<2021-06-20 Sun 10:33>

If you want to access it from any emacs session, put

(defun insert-now-timestamp()
  "Insert org mode timestamp at point with current date and time."
  (interactive)
  (org-insert-time-stamp (current-time) t))

in your .emacs file. You may then call the function with M-x insert-now-timestamp.

Emacs 27.2, org mode 9.4.4.

Edit: I now realise this does the same thing as @anachronic's solution. I however leave it here for reference.

Niclas Börlin
  • 277
  • 4
  • 10
2

On my installation

C-u C-c .

inserts a date-with-time stamp

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
2

Just give you some other options:

  1. If you are using windows system, you can use AutoHotKey to achieve this.
  2. If you can install YASnippet for emacs, it also have the shortcut to insert current date and time.

These two options are very powerful tools, not for just insert date and time.

Tony
  • 354
  • 1
  • 3
  • 11