Currently I add the creation time to my org files with +date: %U in the template string. Works fine and is human readable.

I also would like to have that for the modification time, too.

I know org-roam-timestamps mode. But the format is not customizable and just a bunch of numbers in YYYYMMDDHHMMSS format.

  • Write a function to add a property in whatever format you want. Then add the function to before-save-hook so that it will be run just before the buffer is saved.
    – NickD
    Jan 9, 2022 at 14:13
  • 1
    @NickD And there is already a function for this. gnu.org/software/emacs/manual/html_node/autotype/…
    – nichijou
    Jan 9, 2022 at 16:30
  • 1
    @nichijou: Please consider adding that info as an answer to the question.
    – Drew
    Jan 9, 2022 at 17:51

1 Answer 1


Emacs has a built-in package time-stamp for this scenario.

(add-hook 'before-save-hook #'time-stamp) ; the eponymous function that does the work.

(with-eval-after-load 'time-stamp
  (setq time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S")
  (setq time-stamp-start "^date-of-update: ")
  (setq time-stamp-end "$")
  (setq time-stamp-line-limit 4))
  ;; all above options are safe as local.

Now you place "date-of-update: " at the first 4 line of your buffer. Then everytime you save your buffer, the timestamp is updated automacically.

ref: https://www.gnu.org/software/emacs/manual/html_node/autotype/Timestamps.html

  • Thanks a lot for the code. I am afraid I'm to far a way from lisp to understand how to integrate that into my init.el and my org-roam config. It is a lack of basic knowledge I know. My apologize. Btw: What does the ^ in front of date-of-update mean?
    – buhtz
    Jan 10, 2022 at 12:41
  • 1
    @buhtz regexp thing, "^" & "$" match line-begin and line-end respectively.
    – nichijou
    Jan 10, 2022 at 12:43
  • 1
    @buhtz Your can just copy-paste the code and alter time-stamp-format and time-stamp-format part as per your need. I believe it will work.
    – nichijou
    Jan 10, 2022 at 12:50

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.