1.0.165 timestamp formatting in new template


I tried to get the correct timestamp format

This works:

{{#custom_datetime}}MMMM dddd{{/custom_datetime}}

and gives:

August Sunday

But ideally, I’d like to get this:

Sonntag, 18. August 2019 16:43 Uhr (6 Tage zuvor)

Is this possible?



1 Like

Best I can suggest (through just experimenting with different values) is:

{{#custom_datetime}}dddd, DD. MMMM YYYY HH:mm U\hr{{/custom_datetime}}

You have to escape the “h” in “Uhr” otherwise it inserts an “hour” value.

I can’t see how a date code can give you a value for “x days ago”

1 Like

Joplin simply passes the date format to moment.js for rendering. As dpoulton has said, I don’t think an x days ago template will work, but otherwise everything else should be okay.
That said, it should be possible to create a new template function that would allow “x days ago” using mustache and moment.

The relavent code is in TemplateUtils.js specifically in the view object. I’m sure a pull request would be merged if you added this feature.


I have had a play and these appear to be some values you can use to format the date/time however you want it.


Sunday 18 August 2019 7:35 and 45 seconds pm

Value Output Note
d 0 Day of the week (0-6)
dd Su Day of the week (name abbreviated 2 chars)
ddd Sun Day of the week (name abbreviated 3 chars)
dddd Sunday Day of the week (name full)
D 18 Date (numeric)
Do 18th Date (numeric with suffix)
DD 18 Date (numeric always 2 digits)
DDD 230 Day of the year
w 34 Week of the year
M 8 Month (numeric)
MM 08 Month (numeric always 2 digits)
MMM Aug Month (name abbreviated)
MMMM August Month (name full)
Y 2019 Year (full)
YY 19 Year (abbreviated)
YYYY 2019 Year (full)
h 7 Hour (12 hour clock)
hh 07 Hour (12 hour clock always 2 digits)
H 19 Hour (24 hour clock)
HH 19 Hour (24 hour clock always 2 digits)
m 35 Minutes
mm 35 Minutes (always 2 digits)
s 45 Seconds
ss 45 Seconds (always 2 digits)
a pm am / pm indicator


{{#custom_datetime}}dddd, D. MMMM Y HH:mm U\hr{{/custom_datetime}}
Sunday, 18. August 2019 19:35 Uhr

{{#custom_datetime}}dddd, Do MMMM Y h:mm:ssa{{/custom_datetime}}
Sunday, 18th August 2019 7:35:45pm

It looks like moment.js has a .fromNow(); function but I am not a programmer and so I assume from calebjohn’s comment above it would require a new template function to be created to use it.


@dpoulton Thanks for this useful info

From reading the moment.js page referenced above I saw that it allows data to be escaped using square brackets [ ].

I found that this also works within {{#custom_datetime}} so you can create a timestamp “boilerplate” in a template using just one set of {{#custom_datetime}} tags.

For instance:

If you have the multimarkdown table extension enabled, this:

{{#custom_datetime}}[| Created: |]dddd, D MMMM Y HH:mm \hr\s[|||
| :--- | :---: | :--- | :---: |
| Day: |]DDD[| Week: |]w[ |]{{/custom_datetime}}

Automatically creates:


At least it does for me!!

Not overly useful but kinda cool…

I’m going to stop now as I have abused merlinuwe’s thread far too much…


Thank you very much for the clearifications in text and as a reference and the really cool table.

The translation into other languages and “(6 Tage zuvor)” would be nice, to make the content look more professional.

Good point, I just assumed it did that naturally, I’ll make a pull request.

edit: pull request here

how would i get it to say Week of: {{date_of_monday_for_current_week}}? also maybe an option to select the start day of the week.

@jkassel welcome to the forum.

It is a while since I used this feature but I believe that the date manipulation can only apply to the current date. @CalebJohn mentioned above that the date is displayed using moment.js and after looking at the moment.js page there does not obviously appear to be the function you are looking for. I am not a programmer so I do not know whether it could ever be implemented.

As @dpoulton said I don’t think this is possible with the current template setup. This could be added, but do you know of any template system that has this functionality? I would rather follow a standard for this sort of thing rather than hacking in the behavior.

1 Like

Hey @CalebJohn

Since you've done the coding for this, I have a few questions:

Is there any way, we can set a title as well?

Currently, when I select Create note from template, the title remains empty. However, there are good use cases for having the title populated as well. Can we make this happen somehow?
e.g. use the first line of the template for the title. or use a marker: [title]=.... so that iff [title]= is in the first line, use the rest as the title:

[title]=Week {{#custom_datetime}}WW{{/custom_datetime}}

how would i get it to say Week of: {{date_of_monday_for_current_week}}? also maybe an option to select the start day of the week.

I just came across this use-case myself, where I need the date of Monday (in the current week).
I'd like to implement {{monday}}. I can do this in a few minutes, but I won't waste my time, if you think this is not going to be merged.

Update: or better yet, {{bowm}} (beginning of week monday) and {{bows}} (beginning of week sunday), since some people's week start on Sunday instead of Monday.


Is there any way, we can set a title as well?

Yes this could be done. It would take some amount of refactoring because currently the template code only returns a string (which is the body of the note). I don't think this would be a very big pull request, the more challenging bit is defining the template structure for including a title.
I think initially I figured that the first line of the template would become the title of the new note, although this doesn't seem to work and I'm not sure if it ever did.

how would i get it to say Week of: {{date_of_monday_for_current_week}}? also maybe an option to select the start day of the week.

I think this is a great suggestion, but I'm not sure about the current status of templates in Joplin.
I think it makes sense to disconnect templates from Joplin and make the functionality into a plugin. I haven't taken the time to completely investigate it yet, but I'm fairly sure that it will fit in easily with the plugin interface.

Come to think of it, this won't really work, since we can also insert a template into an existing note.
However, if we used something like:


the parsing becomes easy. When creating a note, use it for the title, if inserting into an existing note, ignore it.
And we'd only check the first line for that marker. If it were on line > 1, it would become part of the text.

Unfortunately I don't know how to do that. In the meantime, we should still be allowed to add improvements to the existing code.

I've already implemented {{bowm}} and {{bows}}. But I will wait a few days, before creating a PR....

I don't think we can wait until there's a way to get the templating system done as a plugin.

This is a small change that helps with usability a lot. At least @jkassel (besides me) will be happy about it. I certainly have missed this for a while now and especially at work this will make my life easier.

1 Like

Necro-ing an old thread to add a heads-up - I have been inserting the week-of-year in my daily notes template, and recently I discovered that there was a difference between what ended up in my daily notes, and what was in my other calendars.

Turns out, there's "week of year" (w), and "ISO week of year" (W), and the two are different. At least in Europe, it seems like the latter is used.