# Reference - Template Time Date Variables

**URL:** <https://discourse.joplinapp.org/t/reference-template-time-date-variables/24672>\
**Category:** Lounge\
**Tags:** tips-and-tricks\
**Created:** [25 March 2022 13:28 UTC](https://discourse.joplinapp.org/t/reference-template-time-date-variables/24672 "2022-03-25T13:28:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpoulton](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/dpoulton/32/29723_2.png) [@dpoulton](https://discourse.joplinapp.org/u/dpoulton)\
**Post date:** [25 March 2022 13:28 UTC](https://discourse.joplinapp.org/t/reference-template-time-date-variables/24672/1 "2022-03-25T13:28:15Z")

</div>

I recently stumbled across [this old post](https://discourse.joplinapp.org/t/1-0-165-timestamp-formatting-in-new-template/3219) 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](https://en.wikipedia.org/wiki/ISO_8601#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](https://github.com/joplin/plugin-templates) paste the text into a template and then generate a note from that template.

[datetime\_template.txt](https://discourse.joplinapp.org/uploads/short-url/14Ga1oIdjjPxZQOSVX739iFiPXO.txt) (6.3 KB)

---

<div class="post-metadata">

**Author:** ![shbach](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/shbach/32/4312_2.png) [@shbach](https://discourse.joplinapp.org/u/shbach)\
**Post date:** [25 March 2022 15:30 UTC](https://discourse.joplinapp.org/t/reference-template-time-date-variables/24672/2 "2022-03-25T15:30:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dpoulton](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/dpoulton/32/29723_2.png) [@dpoulton](https://discourse.joplinapp.org/u/dpoulton)\
**Post date:** [25 March 2022 16:08 UTC](https://discourse.joplinapp.org/t/reference-template-time-date-variables/24672/3 "2022-03-25T16:08:01Z")

</div>

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](https://github.com/laurent22/joplin/pull/4023).

---

<div class="post-metadata">

**Author:** ![shbach](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/shbach/32/4312_2.png) [@shbach](https://discourse.joplinapp.org/u/shbach)\
**Post date:** [25 March 2022 17:56 UTC](https://discourse.joplinapp.org/t/reference-template-time-date-variables/24672/4 "2022-03-25T17:56:36Z")

</div>

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](https://github.com/joplin/plugin-templates/issues/61)
