Templater
Templater copied to clipboard
tp.file.creation_date gets unix epoch date instead of file date
Plugin informations (please complete the following information):
- OS: Pop!_OS 21.04
- Templater version: 1.9.9
- Obsidian version: v0.12.15
- Templater settings:
- Folder location: "Templates/"
- Template Used: Quick Example from https://silentvoid13.github.io/Templater/docs/#quick-example
Describe the bug
tp.file.creation_date()
(likely only on linux / Pop!_OS) is returning 1969-12-31 17:00
which appears to be the Unix Epoch time. It does not appear to matter if the file has existed for a while, been copied from another directory, created via another program or terminal or within Obsidian itself.
<!--- This code in a template -->
---
creation date: <% tp.file.creation_date() %>
modification date: <% tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm:ss") %>
---
<!--- Is creating this code in a new file -->
---
creation date: 1969-12-31 17:00
modification date: Tuesday 5th October 2021 19:05:39
---
Expected behavior
<!--- Should create something similar to this in a new file -->
---
creation date: Tuesday 5th October 2021 19:05:39
modification date: Tuesday 5th October 2021 19:05:39
---
I've had this happen to me as well (on macOS BigSur 11.4) and found a bit of a workaround:
- Insert the template like normal.
- Do a
Ctrl
/Cmd
+A
->Backspace
. - Insert the template again.
I've been using Templater for a month or two now, but this is my first time coming to the repo. If I can find some spare time, I'll see if I can't find the cause for the bug 😅
Same for me, I'm using elementary OS which is also an Ubuntu-based Linux distro. For me, it returns Thursday 1st January 1970, 07:00
.
Can you check if the creation date is the same at the filesystem level and also at the Obsidian metadataCache level? I've seen this happen a few times on Android but Licat has never commented on it (to my knowledge).
Yep, they're the same.
That command is just reading the created/modified date from the file as set in obsidian. I believe if there is an error it is upstream of the plugin. Closing.