This is probably a beginner’s question, but I’m currently struggling with a (mustache) template. Yesterday, I’ve downloaded the “Draftsidian” action from our directory. All works fine, except of the {{createdAt}} parameter that is handing over UTC instead of my local time. I’ve tried to kind of re-format that parameter but it failed miserably.
Template as follows:
—
tags: {{tags}
created: {{createdAt}}
—
{{body}}
Question: Is there anything I can do to get “local time” instead of UTC … for {{createdAt}}?
Thanks a lot in advance for your help.
Mustache Templates | Drafts User Guide - might help you here.
e.g. assuming the createdAt value is Jan. 1 1970:
{{ format(createdAt, formats.shortDate) }} => 1/1/70
{{ format(createdAt, “%Y-%m-%d”) }} => 1970-01-01
Your answer didn’t solve my problem, but you still pointed me in the right direction.
Meanhwile I was able to find the following solution:
{{ format(createdAt, %y-%m-%d) }} {{ adjustDate(createdAt, “+3 hours”, %H:%M) }}
Thanks anyway for your help @jsamlarose
1 Like
First, you should use one adjusted date tag. Your version would be returning the incorrect date for the 3 hours running up to midnight.
But, createdAt
should be returning dates in the local time zone. What do you get if you output timezone (%Z
) in your format? Like:
{{ format(createdAt, "%y-%m-%d %H:%M %Z %z") }}
I’m currently getting CDT -0500
for Central Daylight Time here.
Wonderful, thanks! That did the trick. Works like a charm. I had tried it myself with “%y-%m-%d %H:%M”. But I had forgotten the “%Z %z” at the end. So thanks again!