Templater file creation date repeatedly shows the same old date

I use the templater plugin for blank notes, so all new notes have this in the “Date Created” tag:

<% tp.file.creation_date() %>

In my daily not template, it works just fine, so when I create a new daily note, it inserts the current date, but for my blank notes, it always inserts 10/05/2023 and I can’t figure out why or how to fix it.

The code for the blank notes is exactly the same as the code for the dailies, so I don’t get why it works for one but not the other.

I’m not really sure what to try, so I’m open to any and all suggestions.

Hello.

If you put these two into the same template, what date or dates do they show when run?

// Date now
<% tp.date.now() %>

// Date creation date
<% tp.file.creation_date() %>

For further context, tp.file.creation_date() should reflect the date in the file’s metadata on your host filesystem, while tp.date.now() should retrieve the current datetime via moment.js from your system clock.

I would check if the files are indeed all being created with that date in the date created column of your file explorer. If so, the problem isn’t with templater, but with either obsidian or your host filesystem/OS.

To put it clearer - what previous answers already outlined - you should understand, that <% tp.file.creation_date() %> is meant to retrieve the creation date of a file that has already been created - so this is probably not, what you want.

The creation date in this case is the date when the file was physically created on your devices file system. This may change when you sync or backup and restore your Obsidian files, so if your process relies on the real creation dates of your notes it is strongly recommended to save it permanently in your frontmatter - as you already seem to - and let queries point to your frontmatter property instead of the native file.ctime.

To achieve this you will have to set your

to <% tp.date.now() %> when creating new files with Templater.

1 Like

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