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()): 23-Aug-17
DateFormat(now(),"mmm-dd-yyyy"):Aug-23-2017
 
DateFormat(now(),"m"): 8
DateFormat(now(),"mm"): 08
DateFormat(now(),"mmm"): Aug
DateFormat(now(),"mmmm"): August
 
DateFormat(now(),"d"): 23
DateFormat(now(),"dd"): 23
DateFormat(now(),"ddd"): Wed
DateFormat(now(),"dddd"): Wednesday
 
DateFormat(now(),"y"): 17
DateFormat(now(),"yy"): 17
DateFormat(now(),"yyyy"): 2017
 
DateFormat(now(),"short"): 8/23/17
DateFormat(now(),"medium"): Aug 23, 2017
DateFormat(now(),"long"): August 23, 2017
DateFormat(now(),"full"): Wednesday, August 23, 2017
 
TimeFormat(now()): 08:55 PM
TimeFormat(now(),"hh:mm:ss t"):08:55:54 P
TimeFormat(now(),"hh:mm:ss tt"):08:55:54 PM
12 hour format
TimeFormat(now(),"h"): 8
TimeFormat(now(),"hh"): 08
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 20
TimeFormat(now(),"HH"): 20
 
TimeFormat(now(),"m"): 55
TimeFormat(now(),"mm"): 55
 
TimeFormat(now(),"s"): 54
TimeFormat(now(),"ss"): 54
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 8:55 PM
TimeFormat(now(),"medium"): 8:55:54 PM
TimeFormat(now(),"long"): 8:55:54 PM EDT
TimeFormat(now(),"full"): 8:55:54 PM EDT



Time: 08:55 PM