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()): 13-Apr-21
DateFormat(now(),"mmm-dd-yyyy"):Apr-13-2021
 
DateFormat(now(),"m"): 4
DateFormat(now(),"mm"): 04
DateFormat(now(),"mmm"): Apr
DateFormat(now(),"mmmm"): April
 
DateFormat(now(),"d"): 13
DateFormat(now(),"dd"): 13
DateFormat(now(),"ddd"): Tue
DateFormat(now(),"dddd"): Tuesday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 4/13/21
DateFormat(now(),"medium"): Apr 13, 2021
DateFormat(now(),"long"): April 13, 2021
DateFormat(now(),"full"): Tuesday, April 13, 2021
 
TimeFormat(now()): 01:38 PM
TimeFormat(now(),"hh:mm:ss t"):01:38:57 P
TimeFormat(now(),"hh:mm:ss tt"):01:38:57 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"): 38
TimeFormat(now(),"mm"): 38
 
TimeFormat(now(),"s"): 57
TimeFormat(now(),"ss"): 57
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 1:38 PM
TimeFormat(now(),"medium"): 1:38:57 PM
TimeFormat(now(),"long"): 1:38:57 PM EDT
TimeFormat(now(),"full"): 1:38:57 PM EDT



Time: 01:38 PM