Name

DateFormat

Synopsis

DateFormat(date [, mask])

Returns date formatted according to mask. If no value is specified for mask, DateFormat() uses the default dd-mmm-yy. Valid entries for mask are:

Mask

Description

d

Day of the month as a number with no leading zero for single-digit days

dd

Day of the month as a number with a leading zero for single-digit days

ddd

Three-letter abbreviation for day of the week

dddd

Full name of the day of the week

gg

Period/era; currently ignored

m

Month as a number with no leading zero for single-digit months

mm

Month as a number with a leading zero for single-digit months

mmm

Three-letter abbreviation for the month

mmmm

Full name of the month

y

Last two digits of year with no leading zero for years less than 10

yy

Last two digits of year with a leading zero for years less than 10

yyyy

Four-digit year

Note that DateFormat( ) supports U.S. date formats only. To use locale-specific date formats, see the LSDateFormat( ) function. Examples:

<CFSET TheDate = Now(  )>

<CFOUTPUT>
TheDate = #DateFormat(TheDate, 'mm/dd/yyyy')#
<P>
m/d/yy: #DateFormat(TheDate, 'm/d/yy')#<BR>
mm/dd/yy: #DateFormat(TheDate, 'mm/dd/yy')#<BR>
mm/dd/yyyy: #DateFormat(TheDate, 'mm/dd/yyyy')#<BR>
dd/mm/yyyy: #DateFormat(TheDate, 'dd/mm/yyyy')#<BR>
dd mmm yy: #DateFormat(TheDate, 'dd mmm yy')#<BR>
dddd mmmm dd, yyyy: #DateFormat(TheDate, 'dddd mmmm dd, yyyy')#<BR>
</CFOUTPUT>

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.