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()): 29-Jan-22
DateFormat(now(),"mmm-dd-yyyy"):Jan-29-2022
 
DateFormat(now(),"m"): 1
DateFormat(now(),"mm"): 01
DateFormat(now(),"mmm"): Jan
DateFormat(now(),"mmmm"): January
 
DateFormat(now(),"d"): 29
DateFormat(now(),"dd"): 29
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 2022
DateFormat(now(),"yy"): 22
DateFormat(now(),"yyyy"): 2022
 
DateFormat(now(),"short"): 1/29/22
DateFormat(now(),"medium"): Jan 29, 2022
DateFormat(now(),"long"): January 29, 2022
DateFormat(now(),"full"): Saturday, January 29, 2022
 
TimeFormat(now()): 03:50 AM
TimeFormat(now(),"hh:mm:ss t"):03:50:42 A
TimeFormat(now(),"hh:mm:ss tt"):03:50:42 AM
12 hour format
TimeFormat(now(),"h"): 3
TimeFormat(now(),"hh"): 03
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 3
TimeFormat(now(),"HH"): 03
 
TimeFormat(now(),"m"): 50
TimeFormat(now(),"mm"): 50
 
TimeFormat(now(),"s"): 42
TimeFormat(now(),"ss"): 42
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 3:50 AM
TimeFormat(now(),"medium"): 3:50:42 AM
TimeFormat(now(),"long"): 3:50:42 AM EST
TimeFormat(now(),"full"): 3:50:42 AM EST



Time: 03:50 AM