Returns a formatted date/time value. If no mask is specified, DateFormat function returns date value using the dd-mmm-yy format.
See also Now, CreateDate, and ParseDateTime.
DateFormat(date [, mask ])
Date/time object in the period from 1601 AD to 9999 AD.
Set of characters that are used to show how ColdFusion should display the date:
d
-- Day of the month as digits with no leading zero for single-digit days. dd
-- Day of the month as digits with a leading zero for single-digit days. ddd
-- Day of the week as a three-letter abbreviation. dddd
-- Day of the week as its full name. m
-- Month as digits with no leading zero for single-digit months. mm
-- Month as digits with a leading zero for single-digit months. mmm
-- Month as a three-letter abbreviation. mmmm
-- Month as its full name. y
-- Year as last two digits with no leading zero for years less than 10. yy
-- Year as last two digits with a leading zero for years less than 10. yyyy
-- Year represented by four digits. gg
-- Period/era string. Currently ignored, but reserved for future use.When passing a date/time value as a string, make sure it is enclosed in quotes. Otherwise, it is interpreted as a number representation of a date/time object, returning undesired results.
<!--- This example shows the various types of output possible with DateFormat ---> <HTML> <HEAD> <TITLE> DateFormat Example </TITLE> </HEAD> <CFSET todayDate=Now()> <BODY> <H3>DateFormat Example</H3> <P>Today's date is <CFOUTPUT>#todayDate#</CFOUTPUT>. <P>Using DateFormat, we can display that date in a number of different ways: <CFOUTPUT> <UL> <LI>#DateFormat(todayDate)# <LI>#DateFormat(todayDate, "mmm-dd-yyyy")# <LI>#DateFormat(todayDate, "mmmm d, yyyy")# <LI>#DateFormat(todayDate, "mm/dd/yyyy")# <LI>#DateFormat(todayDate, "d-mmm-yyyy")# <LI>#DateFormat(todayDate, "ddd, mmmm dd, yyyy")# <LI>#DateFormat(todayDate, "d/m/yy")# </UL> </CFOUTPUT> </BODY> </HTML>