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()): 18-Apr-21
DateFormat(now(),"mmm-dd-yyyy"):Apr-18-2021
 
DateFormat(now(),"m"): 4
DateFormat(now(),"mm"): 04
DateFormat(now(),"mmm"): Apr
DateFormat(now(),"mmmm"): April
 
DateFormat(now(),"d"): 18
DateFormat(now(),"dd"): 18
DateFormat(now(),"ddd"): Sun
DateFormat(now(),"dddd"): Sunday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 4/18/21
DateFormat(now(),"medium"): Apr 18, 2021
DateFormat(now(),"long"): April 18, 2021
DateFormat(now(),"full"): Sunday, April 18, 2021
 
TimeFormat(now()): 04:22 AM
TimeFormat(now(),"hh:mm:ss t"):04:22:50 A
TimeFormat(now(),"hh:mm:ss tt"):04:22:50 AM
12 hour format
TimeFormat(now(),"h"): 4
TimeFormat(now(),"hh"): 04
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 4
TimeFormat(now(),"HH"): 04
 
TimeFormat(now(),"m"): 22
TimeFormat(now(),"mm"): 22
 
TimeFormat(now(),"s"): 50
TimeFormat(now(),"ss"): 50
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 4:22 AM
TimeFormat(now(),"medium"): 4:22:50 AM
TimeFormat(now(),"long"): 4:22:50 AM EDT
TimeFormat(now(),"full"): 4:22:50 AM EDT



Time: 04:22 AM