Jump to content

Umbraco/Reference/umbraco.library/FormatDateTime

From Wikibooks, open books for an open world

Purpose:

[edit | edit source]

This function allows you to format a date.


Arguments:

[edit | edit source]

FormatDateTime('String Date'-'String Date')
FormatDateTime('String Format')

String Date = d-d
String Format = MMM

String Format Codes:

[edit | edit source]

Month
MMMM = Full month name spelled out ('August')
MMM = Abbreviated month name ('Aug')
MM = 2 digit month ('08')
%M = 1 or 2 digit month ('8')

Day
dddd = Full day of week ('Thursday')
ddd = Abbreviated day of the week ('Thu')
dd = 2 digit day ('06')
d = 1 or 2 digit day ('6')

Year
y or yy = 2 digit year ('99')
yyyy = 4 digit year ('1999')

Hour
h = 1 or 2 digit hour ('9')
hh = 2 digit hour ('09')
H = 24 hour ('21')

Minute
m = 1 or 2 digit minute ('3')
mm = 2 digit minute('03')

AM/PM
tt = AM/PM

RFC-1123 date-time
r = the date-time following the RFC-1123 pattern
For example: Wed, 02 Oct 2002 13:00:00 GMT

Example XSLT Usage:

[edit | edit source]

<xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'MMMM d, yyyy')"/>

<xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'r') "/>