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-24
DateFormat(now(),"mmm-dd-yyyy"):Dec-01-2024
 
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"): Sun
DateFormat(now(),"dddd"): Sunday
 
DateFormat(now(),"y"): 2024
DateFormat(now(),"yy"): 24
DateFormat(now(),"yyyy"): 2024
 
DateFormat(now(),"short"): 12/1/24
DateFormat(now(),"medium"): Dec 1, 2024
DateFormat(now(),"long"): December 1, 2024
DateFormat(now(),"full"): Sunday, December 1, 2024
 
TimeFormat(now()): 01:25 PM
TimeFormat(now(),"hh:mm:ss t"):01:25:32 P
TimeFormat(now(),"hh:mm:ss tt"):01:25:32 PM
12 hour format
TimeFormat(now(),"h"): 1
TimeFormat(now(),"hh"): 01
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 13
TimeFormat(now(),"HH"): 13
 
TimeFormat(now(),"m"): 25
TimeFormat(now(),"mm"): 25
 
TimeFormat(now(),"s"): 32
TimeFormat(now(),"ss"): 32
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 1:25 PM
TimeFormat(now(),"medium"): 1:25:32 PM
TimeFormat(now(),"long"): 1:25:32 PM EST
TimeFormat(now(),"full"): 1:25:32 PM EST



Time: 01:25 PM