Add timestamps and datestamps to notes w/ only core plugins

Giving this its own post with a clear title, so it’s easy to reference later.

You can automatically insert the date or time while writing a note using Obsidian’s core Templates plugin. You don’t need the Templater or Natural Language plugins.

In this case, it’s better to think of Templates as “partial” chunks of stuff you use to build up a note, rather than a “full” template of a complete note.

To create a a timestamp, create a new file in your Templates folder called “timestamp” (or “thisbenow” or whatever), and add the variable for the current time. As a dirty American with only 12 hours on a clock, mine is:

{{time:h:mm a}}

To add a timestamp anywhere you’re typing in Obsidian, activate the “insert template” command and choose the Timestamp template. Voila, you have the current time magically entered into the note.

If you’re a sophisticated aficionado of the 24-hour clock, you can just use {{time}}. (Complete formatting options available from the moments website).

Create a datestamp the same way. I like to link everything to and from my Daily Notes, so my datestamp template adds the date as a link:

[[{{date:YYYY-MM-DD - ddd MMM D}}]]

Two pro-tips I’ve stolen from elsewheres:

  1. If you use Templates a lot, make the Template command easy to get to as a keyboard shortcut or as a pinned command.

  2. If you specify the format in the template file rather than Templates settings, then the format follows the file when it synchs, and you won’t have to update settings on every device.

7 Likes

Is there a way to set the hotkey to insert the specific template with the time/date stamp?
(I’ve looked here )

@gabecolors, I’ve not gotten into custom hot keys, and I only use a few default ones.

I did find this plugin:

But I haven’t tried it.

1 Like

This is very interesting. Do you happen to know if there is a way to change the resulting week for example. In my company instead of using ISO weeks they have their own which is offset by 1, for example it is week 8 now and not week7. Any way I can make the result show up as w8?

Here I am 30 minutes later after going down the rabbit hole of moment and templater plugin. I was able to solve my case using templater pluging and this is the command I used to make the week show up one more than the ISO weeks.
<%tp.date.now(“YYYY”)%> WW <% tp.date.now(“WW.d”, “P+1W”) %> with this command I get this result 2022 WW 08.3 as I desired showing week 8 instead of 7 as per ISO.

This is really basic but I cannot get the template to resolve. Whether I use templates or templater I add a basic {{date:YYYY-MM-DD}}

it doesn’t resolve. I must be missing something.

I use espanso and configured ::date to print the current date whenever I need that in a document (not in a template).

1 Like

The syntax with the {{ }} will only work in the core Templates plugin, not Templater. Are you putting that snippet with {{date:... in a file in whatever folder you have told the Templates plugin settings holds your templates (mine is called, uncreatively, “templates”), and then inserted it into your current file with “Insert Template:” and picking the filename of the file where you put the snippet?