DATE and TIME formatting code examples

"now()" returns the current system time. You can replace "now()" with any valid date field. For example:
     <cfset MyDateTimeNow = now()>
     #DateFormat(MyDateTimeNow,"mm-dd-yy")#


DateFormat(now()): 21-Sep-21
DateFormat(now(),"mmm-dd-yyyy"):Sep-21-2021
 
DateFormat(now(),"m"): 9
DateFormat(now(),"mm"): 09
DateFormat(now(),"mmm"): Sep
DateFormat(now(),"mmmm"): September
 
DateFormat(now(),"d"): 21
DateFormat(now(),"dd"): 21
DateFormat(now(),"ddd"): Tue
DateFormat(now(),"dddd"): Tuesday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 9/21/21
DateFormat(now(),"medium"): Sep 21, 2021
DateFormat(now(),"long"): September 21, 2021
DateFormat(now(),"full"): Tuesday, September 21, 2021
 
TimeFormat(now()): 12:53 PM
TimeFormat(now(),"hh:mm:ss t"):12:53:03 P
TimeFormat(now(),"hh:mm:ss tt"):12:53:03 PM
12 hour format
TimeFormat(now(),"h"): 12
TimeFormat(now(),"hh"): 12
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 12
TimeFormat(now(),"HH"): 12
 
TimeFormat(now(),"m"): 53
TimeFormat(now(),"mm"): 53
 
TimeFormat(now(),"s"): 3
TimeFormat(now(),"ss"): 03
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 12:53 PM
TimeFormat(now(),"medium"): 12:53:03 PM
TimeFormat(now(),"long"): 12:53:03 PM EDT
TimeFormat(now(),"full"): 12:53:03 PM EDT



Time: 12:53 PM