I would like to create a yasnippet snippet which will insert automatically the current timestamp. I have found a code which actually prints the timestamp but I do not know how to integrate into a yasnippet snippet. Any way to do this?

Example. I would like that pressing "weather" and then TAB I get 2017-07-29, time = so I can type the weather.

1 Answer 1


As with this recent question, you can use embedded Emacs-lisp code.

# -*- mode: snippet -*-
# key: weather
# --
`(format-time-string "%Y-%m-%d, time = ")`$0

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.