Knowledge Base

T4 tags: Format dates

Last Modified:
14 Dec 2018
User Level:
Power User

Format dates

You can format Meta dates and date elements in the Content layout. With no date formatting, a default date format will be used.

To format the date of content type elements use the attribute date_format
To format the date of meta tags use format

When selecting dates/times in the Generate T4 Tag you can choose from the following options:

ValueOutput
MM/dd/yyyy 09/25/1980
M/d/yy 4/5/94
dd/MM/yyyy 04/10/1970
d/M/yy 4/1/86
EEE, MMM d, ''yy Tue, Feb 3, '59
EEEE, MMMM d, yyyy Monday, December 8, 1980
hh:mm a 09:30 AM
h:mm a 9:30 PM
HH:mm 21:30
HH:mm:ss z 21:30:56 PDT
HH:mm:ss Z 21:30:56 -0700
h 'o''clock' a, zzzz 9 o'clock PM, Pacific Daylight Time
MM/dd/yyyy 'at' HH:mm:ss z 05/29/1997 at 21:30:56 PDT
h:mm a 'on' EEE, d MMMM 9:30 AM on Sat, 22 November
yyyyMMdd'T'HHmmss'Z' iCalendar .ics format
yyyy-MM-dd'T'HH:MM:ss'Z' Google/Outlook format

Custom formats can be created based on the following:

LetterDate or Time ComponentPresentationExamples
G Era designator Text AD
y Year Year 1996; 96
M Month in year Month July; Jul; 07
w Week in year Number 27
W Week in month Number 2
D Day in year Number 189
d Day in month Number 10
F Day of week in month Number 2
E Day in week Text Tuesday; Tue
a Am/pm marker Text PM
H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24
K Hour in am/pm (0-11) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone RFC 822 time zone -800

Examples

The date 22 January 13 or 9 January 13

<t4 date_format="d MMMM yy" type="content" name="the date" output="normal" modifiers="" />

 The date 22 January 2013 or 9 January 2013


<t4 type="content" date_format="d MMMM yyyy" name="the date" output="normal" modifiers="" />

The date 22 01 2013 or 09 01 2013

<t4 type="content" date_format="d MM yy" name="the date" output="normal" modifiers="" />

The date Friday, Mar. 21. 2014:


<t4 type="content" date_format="EEEE, MMM. d. yyyy" name="the date" output="normal" modifiers="" />

The date Last Modified 22 01 2013

<t4 type="meta" format="d MM yyyy" meta="last modified" />

Dates in multiple language sites

The locale attributes must be added manually to the tags. The date_format attribute outputs the date in the relevant language so an English page uses the English month names, and for a French page it uses the French month names.

Example tag using the locale:

<t4 type="content" name="Date Released" output="normal" modifiers="" date_format="d MMMM yyyy" locale="fr" locale_es="en" />