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()): 21-Nov-18
DateFormat(now(),"mmm-dd-yyyy"):Nov-21-2018
 
DateFormat(now(),"m"): 11
DateFormat(now(),"mm"): 11
DateFormat(now(),"mmm"): Nov
DateFormat(now(),"mmmm"): November
 
DateFormat(now(),"d"): 21
DateFormat(now(),"dd"): 21
DateFormat(now(),"ddd"): Wed
DateFormat(now(),"dddd"): Wednesday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 11/21/18
DateFormat(now(),"medium"): Nov 21, 2018
DateFormat(now(),"long"): November 21, 2018
DateFormat(now(),"full"): Wednesday, November 21, 2018
 
TimeFormat(now()): 12:51 AM
TimeFormat(now(),"hh:mm:ss t"):12:51:25 A
TimeFormat(now(),"hh:mm:ss tt"):12:51:25 AM
12 hour format
TimeFormat(now(),"h"): 12
TimeFormat(now(),"hh"): 12
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 0
TimeFormat(now(),"HH"): 00
 
TimeFormat(now(),"m"): 51
TimeFormat(now(),"mm"): 51
 
TimeFormat(now(),"s"): 25
TimeFormat(now(),"ss"): 25
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 12:51 AM
TimeFormat(now(),"medium"): 12:51:25 AM
TimeFormat(now(),"long"): 12:51:25 AM EST
TimeFormat(now(),"full"): 12:51:25 AM EST



Time: 12:51 AM