/ News

Date formatting

November 2, 2015

You can now specify the format of a post’s date inside a template. For example:

{{#formatDate}} dddd, MMMM Do YYYY, h:mm a {{/formatDate}}
Friday, September 25th 2015, 4:25 pm

When should I use this?

The format of the {{date}} property of each post is still specified on the settings page and is not affected by {{formatDate}}. If you intend to use a single date format, you should just change the option on the settings page. The new {{formatDate}} feature allows you to use multiple date formats across your blog.

Here’s a reference for some of the formatting possibilities. The full list is available in Moment’s documentation.

Month M 1 2 … 11 12
MM 01 02 … 11 12
MMM Jan Feb … Nov Dec
MMMM January February … November December
Day of Month D 1 2 … 30 31
Do 1st 2nd … 30th 31st
DD 01 02 … 30 31
Quarter Q 1 2 3 4
Year YY 70 71 … 29 30
YYYY 1970 1971 … 2029 2030
AM/PM A AM PM
a am pm
Hour H 0 1 … 22 23
HH 00 01 … 22 23
h 1 2 … 11 12
hh 01 02 … 11 12
Minute m 0 1 … 58 59
mm 00 01 … 58 59
Second s 0 1 … 58 59
ss 00 01 … 58 59
Unix Timestamp X 1360013296
Unix Millisecond Timestamp x 1360013296123

Thanks to Frank for suggesting this feature.