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



Time: 04:11 PM