Reference - Template Time Date Variables

I recently stumbled across this old post and it was evident some variables (notably the ISO ones) were missing. So I decided to expand the list of variables a bit. Rather than necro an old post I thought I would just add it as a "lounge" topic for general reference / forum searching.

This list was generated by a template on Friday 25th March 2022 at 17:55 +00:00 and so all these values do work...

custom_datetime

Variables

The below should be enclosed in custom_datetime tags in the template

{{#custom_datetime}}variables{{/custom_datetime}}

Value Output Note
d 5 Day of the week (0-6 = Sun-Sat)
dd Fr Day of the week (name abbreviated 2 characters)
ddd Fri Day of the week (name abbreviated 3 characters)
dddd Friday Day of the week (name full)
e 4 Day of the week (Locale Aware)* (0-6)
E 5 Day of the week (ISO) (1-7 = Mon-Sun)
D 25 Date
Do 25th Date (with suffix)
DD 25 Date (always 2 digits)
DDD 84 Day of the year
DDDo 84th Day of the year (with suffix)
DDDD 084 Day of the year (always 3 digits)
w 12 Week of the year
wo 12th Week of the year (with suffix)
ww 12 Week of the year (always 2 digits)
W 12 Week of the year (ISO)
Wo 12th Week of the year (ISO) (with suffix)
WW 12 Week of the year (ISO) (always 2 digits)
M 3 Month (numeric)
Mo 3rd Month (numeric) (with suffix)
MM 03 Month (numeric always 2 digits)
MMM Mar Month (name abbreviated)
MMMM March Month (name full)
Y 2022 Year (ISO)
YY 22 Year (abbreviated)
YYYY 2022 Year (full)
YYYYYY +002022 Year (Expanded)
y 2022 Era Year
gggg 2022 Week Year for "Week Dates" (e.g. 2022-W12-4)
GGGG 2022 Week Year (ISO) for "Week Dates" (e.g. 2022-W12-5)
Q 1 Quarter
Qo 1st Quarter (with suffix)
h 5 Hour (12 hour clock)
hh 05 Hour (12 hour clock always 2 digits)
H 17 Hour (0-23) (24 hour clock)
HH 17 Hour (0-23) (24 hour clock always 2 digits)
m 55 Minutes
mm 55 Minutes (always 2 digits)
s 17 Seconds
ss 17 Seconds (always 2 digits)
S 6 Fractional Seconds - tenths
SS 62 Fractional Seconds - hundredths
SSS 622 Fractional Seconds - thousandths
a pm am / pm indicator
A PM AM / PM indicator
Z +00:00 Timezone Offset (with colon separator)
ZZ +0000 Timezone Offset
X 1648230917 Unix Timestamp
x 1648230917622 Unix Millisecond Timestamp
N AD Era (abbreviated)
NNNN Anno Domini Era (full)
LT 17:55 Localised format - time*
LTS 17:55:17 Localised format - time (with seconds)*
l 25/3/2022 Localised format - date (no leading zeros)*
L 25/03/2022 Localised format - date*
ll 25 Mar 2022 Localised format - date (short month)*
LL 25 March 2022 Localised format - date (long month)*
lll 25 Mar 2022 17:55 Localised format - date / time (short month)*
LLL 25 March 2022 17:55 Localised format - date / time (long month)*
llll Fri, 25 Mar 2022 17:55 Localised format - day / date / time (short)*
LLLL Friday, 25 March 2022 17:55 Localised format - day / date / time (long)*

* The output format displayed will vary with region for each user

Joplin

Variables

The below should be enclosed in double curly brackets in the template not custom_datetime tags.

{{variable}}

Value Output Note
date 2022-03-25 Date
time 13:07 Time
datetime 2022-03-25 13:07 Date and time
bows 2022-03-20 Date of the beginning of the week (Sunday)
bowm 2022-03-21 Date of the beginning of the week (Monday)

The above display the date / time format as it is set in Joplin

Examples

Friday 25th March 2022 1:07 PM

dddd Do MMMM YYYY h:mm A


Fri 25 Mar 2022 13:07:35.04

ddd DD MMM YYYY HH:mm:ss.SS


2022-03-25T13:07:35+00:00

Y-MM-DDTHH:mm:ssZ


EDIT:

If anyone wants to see how this behaves in their timezone or at different times of the day, here is the template markdown. Install the template plugin paste the text into a template and then generate a note from that template.

datetime_template.txt (6.3 KB)

6 Likes

Nice reference list!

Would there happen to be a way to do a time offset? e.g. I want the time to be offset 72 hrs forward so if on Friday I create a note with {{#custom_datetime}}GGGG-[W]WW{{/custom_datetime}} it will use WW for next week but if I created the note on Monday it would use WW for the current week.

I have not seen anything that suggests that custom_datetime reports anything other than the current date. However I am just a fellow user and I have no idea how all this actually works or what packages @nishantwrp used to create the plugin!

The only non-current date variables I am aware of are the Joplin {{bows}} and {{bowm}} and these were specifically written for Joplin and merged.

Doesn't look like it exists on further investigation, unfortunately. I've created an issue for it: Support time offset · Issue #61 · joplin/plugin-templates · GitHub