{{date}} not returning today's date in templates

The DD-MM-YYYY format you used in the settings of the Template core plugin will return today’s date… but not in Properties … At least, not for a date or date & time type of key :blush: .

I think that you’re probably running into an issue similar as this one: Properties: Change from "text" to "date&time" rewrites day and year. Month and time unaffected :blush:

When a date or date/time is written on file in YAML (when you create a note/apply a template) for date or date/time type of keys, the only format allowed for this to work correctly when the date or date/time is later on parsed and displayed in Properties is the ISO8601 format (YYYY-MM-DD).

See: Properties: let the user customize the way Dates/Times are saved

In other words, in this case, Properties can’t correctly read the format you used in source mode/YAML and mixes it up when it displays it in Live Preview/Reading mode :blush: .

E.g.: Yesterday was 2023-11-03 which was written/saved as 03-11-2023 in YAML/source mode.

When parsed to be displayed in Properties:

  • DD03 → becomes the year part → 2003

    • (There is/was (?) a truncated way to represent years in ISO where the century is implied (YY-MM-DD) so I can only guess that Properties assumed this is what was used here)
  • MM11 → is still the month part → 11

  • YYYY2023 → becomes the day part → 20

    • (I guess that only the first 2 digits are taken in account here)
  • … which results in Properties (when in Live Preview/Reading mode) → 20-11-2003

A workaround, if you don’t want to change the date format in the Template core plugin so you can use it as it is outside of YAML/Properties (with the {{date}} placeholder), would be to use, in your template, something like :

---
created: {{date:YYYY-MM-DD}}
---

… to bypass the format set in the settings and use the ISO one instead in YAML/Properties :blush: .

2 Likes