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



Time: 07:39 PM