How Do You Format a Date In the Templates?

Standard Date Formatting

Format Specifier      Description

d                                Short date pattern

D                                Long date pattern

f                                 Full date/time pattern (short date)

F                                Full date/time pattern (long time)

g                                General date/time pattern (short time)

G                               General date/time pattern (long time)

M                               Month/day pattern

t                                 Short time pattern

T                                Long time pattern

U                               Universal full date/time pattern

Y                               Year/month pattern


Custom Date Formatting

Format Specifier       Description

d                               The day of the month, from 1 through 31

dd                             The day of the month, from 01 through 31

ddd                           The abbreviated name of the day of the week

dddd                         The full name of the day of the week

h                               The hour, using a 12-hour clock from 1 to 12

hh                             The hour, using a 12-hour clock from 01 to 12

H                              The hour, using a 24-hour clock from 0 to 23

HH                            The hour, using a 24-hour clock from 00 to 23

K                               Time zone information

m                               The minute, from 0 through 59

mm                            The minute, from 00 through 59

M                               The month, from 1 through 12

MM                            The month, from 01 through 12

MMM                         The abbreviated name of the month

MMMM                      The full name of the month

t                                 The first character of the AM/PM designator

tt                                The AM/PM designator

y                                The year, from 0 to 99

yy                              The year, from 00 to 99

yyy                            The year, with a minimum of three digits

yyyy                          The year as a four-digit number

yyyyy                        The year as a five-digit number


Examples:

{{w3_due_date | date:'dd-MM-yyyy'}}

Eg. 25-10-2020


{{w3_due_date | date:'m-dd-yyyy'}}

Eg. 5-10-2020


{{w3_due_date | date:'dddd, mmmm dS, yyyy'}}

Eg. Saturday, June 9th, 2020


{{w3_due_date | date:'mmm dd, yyyy'}}

Eg. 2020-02-15


{{w3_due_date | date:'yyyy-mm-dd'}}

Eg. 2020-02-15

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us