User Guide
DateFormat 449
Date and time values in database query results can vary in sequence and formatting unless you use
functions to format them. To ensure that application users correctly understand displayed dates
and times, Macromedia recommends that you use this function and the
LSDateFormat,
TimeFormat, and LSTimeFormat functions to format resultset values. For more information and
examples, see TechNote 22183, "ColdFusion Server (5 and 4.5.x) with Oracle: Formatting Date and
Time Query Results," on our website at www.coldfusion.com/Support/KnowledgeBase/
SearchForm.cfm.
Example
<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, "short")#
<li>#DateFormat(todayDate, "medium")#
<li>#DateFormat(todayDate, "long")#
<li>#DateFormat(todayDate, "full")#
</ul>
</cfoutput>