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()): 19-Apr-18
DateFormat(now(),"mmm-dd-yyyy"):Apr-19-2018
 
DateFormat(now(),"m"): 4
DateFormat(now(),"mm"): 04
DateFormat(now(),"mmm"): Apr
DateFormat(now(),"mmmm"): April
 
DateFormat(now(),"d"): 19
DateFormat(now(),"dd"): 19
DateFormat(now(),"ddd"): Thu
DateFormat(now(),"dddd"): Thursday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 4/19/18
DateFormat(now(),"medium"): Apr 19, 2018
DateFormat(now(),"long"): April 19, 2018
DateFormat(now(),"full"): Thursday, April 19, 2018
 
TimeFormat(now()): 04:55 PM
TimeFormat(now(),"hh:mm:ss t"):04:55:25 P
TimeFormat(now(),"hh:mm:ss tt"):04:55:25 PM
12 hour format
TimeFormat(now(),"h"): 4
TimeFormat(now(),"hh"): 04
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 16
TimeFormat(now(),"HH"): 16
 
TimeFormat(now(),"m"): 55
TimeFormat(now(),"mm"): 55
 
TimeFormat(now(),"s"): 25
TimeFormat(now(),"ss"): 25
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 4:55 PM
TimeFormat(now(),"medium"): 4:55:25 PM
TimeFormat(now(),"long"): 4:55:25 PM EDT
TimeFormat(now(),"full"): 4:55:25 PM EDT



Time: 04:55 PM