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()): 26-Oct-21
DateFormat(now(),"mmm-dd-yyyy"):Oct-26-2021
 
DateFormat(now(),"m"): 10
DateFormat(now(),"mm"): 10
DateFormat(now(),"mmm"): Oct
DateFormat(now(),"mmmm"): October
 
DateFormat(now(),"d"): 26
DateFormat(now(),"dd"): 26
DateFormat(now(),"ddd"): Tue
DateFormat(now(),"dddd"): Tuesday
 
DateFormat(now(),"y"): 2021
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 10/26/21
DateFormat(now(),"medium"): Oct 26, 2021
DateFormat(now(),"long"): October 26, 2021
DateFormat(now(),"full"): Tuesday, October 26, 2021
 
TimeFormat(now()): 03:26 PM
TimeFormat(now(),"hh:mm:ss t"):03:26:03 P
TimeFormat(now(),"hh:mm:ss tt"):03:26:03 PM
12 hour format
TimeFormat(now(),"h"): 3
TimeFormat(now(),"hh"): 03
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 15
TimeFormat(now(),"HH"): 15
 
TimeFormat(now(),"m"): 26
TimeFormat(now(),"mm"): 26
 
TimeFormat(now(),"s"): 3
TimeFormat(now(),"ss"): 03
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 3:26 PM
TimeFormat(now(),"medium"): 3:26:03 PM
TimeFormat(now(),"long"): 3:26:03 PM EDT
TimeFormat(now(),"full"): 3:26:03 PM EDT



Time: 03:26 PM