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()): 20-Jan-22
DateFormat(now(),"mmm-dd-yyyy"):Jan-20-2022
 
DateFormat(now(),"m"): 1
DateFormat(now(),"mm"): 01
DateFormat(now(),"mmm"): Jan
DateFormat(now(),"mmmm"): January
 
DateFormat(now(),"d"): 20
DateFormat(now(),"dd"): 20
DateFormat(now(),"ddd"): Thu
DateFormat(now(),"dddd"): Thursday
 
DateFormat(now(),"y"): 22
DateFormat(now(),"yy"): 22
DateFormat(now(),"yyyy"): 2022
 
DateFormat(now(),"short"): 1/20/22
DateFormat(now(),"medium"): Jan 20, 2022
DateFormat(now(),"long"): January 20, 2022
DateFormat(now(),"full"): Thursday, January 20, 2022
 
TimeFormat(now()): 05:45 PM
TimeFormat(now(),"hh:mm:ss t"):05:45:42 P
TimeFormat(now(),"hh:mm:ss tt"):05:45:42 PM
12 hour format
TimeFormat(now(),"h"): 5
TimeFormat(now(),"hh"): 05
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 17
TimeFormat(now(),"HH"): 17
 
TimeFormat(now(),"m"): 45
TimeFormat(now(),"mm"): 45
 
TimeFormat(now(),"s"): 42
TimeFormat(now(),"ss"): 42
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 5:45 PM
TimeFormat(now(),"medium"): 5:45:42 PM
TimeFormat(now(),"long"): 5:45:42 PM EST
TimeFormat(now(),"full"): 5:45:42 PM EST



Time: 05:45 PM