Templater <% tp.date.now(") %> does not stay up to date

Things I have tried

Checked my system clock, tried multiple date formats, I get today’s date, but everyday after will still show today’s date and will not update

I just started using Obsidian a few days ago so any help is greatly appreciated

What I’m trying to do

Hi there!

Templater expressions are evaluated at the time of note creation.

So, for your example, if you make a note today the note is written with “8/20/2022”, NOT “<% tp.date.now(‘’) %>”. The Templater expression in the note has been evaluated to its final value and only the value is stored in the note.

Templater expressions only exist in the template, not the notes produced from that template.

Use cases for this are many, but here’s a common example: Make a daily note every day automatically named by the day’s date (and containing links to the previous and next daily notes). Tomorrow, you’d make a new daily note and it will be named by tomorrow’s date. Now you have a journal and later you will be able to see what happened on which day.

Instead, it sounds like you want a dynamic field in a note that’s updated every time you open or change the note. You’ll need a different plugin for this – my suggestion would be Dataview. Someone can probably help you with a DataviewJS expression that will produce the current date.

Hope that helps!

1 Like

Put this:

dv.paragraph(moment().format('dddd Do MMMM, YYYY'))

You can change the format (this part 'dddd Do MMMM, YYYY') by following the docs here: https://momentjs.com/docs/#/displaying/format/

Thank you, Alan! @1012u, as you can see, the members of this community will very much help you with the code snippets needed to do what you want. Welcome to Obsidian!

Thank you, I thought it was something I was doing wrong, but I just misunderstood. I was under the impression that the .now would update to the Windows system clock. I’ll try Dataview. Another add-on to learn, yay
Thanks again

Thanks for the info. The help is really appreciated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.