Returns a formatted date/time value. If no mask is specified, DateFormat
returns the date value in the dd-mmm-yy format. DateFormat
supports dates that have the U.S. date format. For international date support, use LSDateFormat.
DateFormat(date [, mask ])
Now,
CreateDate,
TimeFormat,
ParseDateTime
When passing a date/time value as a string, enclose it in quotes. Otherwise, it is interpreted as a number representation of a date/time object.
Note You can pass the CreateDate function or Now function as the date parameter of DateFormat: #DateFormat(CreateDate(2001, 3, 3))# |
If the switch is set, the default date format returned by the DateFormat
function cannot be parsed in an expression. However, if you specify a mask, indicating the correct order, such as, mm/dd/yyyy, the date returned by this function can be parsed.
<!--- This example shows the types of output 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 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>