Name

DateFormat

Synopsis

                  
                  DateFormat(date [, mask])

Returns date formatted according to mask. Dates must be in the range AD 100-9999. 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

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

gg

Period/era

short

Java short date format

medium

Java medium date format

long

Java long date format

full

Java full date format

Dates passed as literals must be enclosed in quotes. Otherwise, ColdFusion interprets the date as a numeric date. If an invalid mask is passed to the function, ColdFusion outputs the invalid characters. Note that DateFormat( ) supports U.S. date formats only. To use locale-specific date formats, see the LSDateFormat( ) function. For information on how ColdFusion MX handles two-digit years, see CreateDate( ). Examples:

<cfset TheDate = Now( )> <cfoutput> TheDate = #DateFormat(TheDate, ...

Get Programming ColdFusion MX, 2nd Edition 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.