Templater icon indicating copy to clipboard operation
Templater copied to clipboard

tp.file.creation_date gets unix epoch date instead of file date

Open jojobyte opened this issue 2 years ago • 4 comments

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
---

jojobyte avatar Oct 06 '21 01:10 jojobyte

I've had this happen to me as well (on macOS BigSur 11.4) and found a bit of a workaround:

  1. Insert the template like normal.
  2. Do a Ctrl/Cmd+A->Backspace.
  3. 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 😅

4lch4 avatar Oct 09 '21 04:10 4lch4

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.

mufidu avatar May 02 '22 23:05 mufidu

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).

AB1908 avatar May 03 '22 18:05 AB1908

Yep, they're the same.

mufidu avatar May 04 '22 12:05 mufidu

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.

shabegom avatar Sep 01 '22 21:09 shabegom