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()): 18-Aug-18
DateFormat(now(),"mmm-dd-yyyy"):Aug-18-2018
 
DateFormat(now(),"m"): 8
DateFormat(now(),"mm"): 08
DateFormat(now(),"mmm"): Aug
DateFormat(now(),"mmmm"): August
 
DateFormat(now(),"d"): 18
DateFormat(now(),"dd"): 18
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 8/18/18
DateFormat(now(),"medium"): Aug 18, 2018
DateFormat(now(),"long"): August 18, 2018
DateFormat(now(),"full"): Saturday, August 18, 2018
 
TimeFormat(now()): 03:46 PM
TimeFormat(now(),"hh:mm:ss t"):03:46:50 P
TimeFormat(now(),"hh:mm:ss tt"):03:46:50 PM
12 hour format
TimeFormat(now(),"h"): 3
TimeFormat(now(),"hh"): 03
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 15
TimeFormat(now(),"HH"): 15
 
TimeFormat(now(),"m"): 46
TimeFormat(now(),"mm"): 46
 
TimeFormat(now(),"s"): 50
TimeFormat(now(),"ss"): 50
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 3:46 PM
TimeFormat(now(),"medium"): 3:46:50 PM
TimeFormat(now(),"long"): 3:46:50 PM EDT
TimeFormat(now(),"full"): 3:46:50 PM EDT



Time: 03:46 PM