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-Nov-17
DateFormat(now(),"mmm-dd-yyyy"):Nov-18-2017
 
DateFormat(now(),"m"): 11
DateFormat(now(),"mm"): 11
DateFormat(now(),"mmm"): Nov
DateFormat(now(),"mmmm"): November
 
DateFormat(now(),"d"): 18
DateFormat(now(),"dd"): 18
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 17
DateFormat(now(),"yy"): 17
DateFormat(now(),"yyyy"): 2017
 
DateFormat(now(),"short"): 11/18/17
DateFormat(now(),"medium"): Nov 18, 2017
DateFormat(now(),"long"): November 18, 2017
DateFormat(now(),"full"): Saturday, November 18, 2017
 
TimeFormat(now()): 09:57 PM
TimeFormat(now(),"hh:mm:ss t"):09:57:59 P
TimeFormat(now(),"hh:mm:ss tt"):09:57:59 PM
12 hour format
TimeFormat(now(),"h"): 9
TimeFormat(now(),"hh"): 09
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 21
TimeFormat(now(),"HH"): 21
 
TimeFormat(now(),"m"): 57
TimeFormat(now(),"mm"): 57
 
TimeFormat(now(),"s"): 59
TimeFormat(now(),"ss"): 59
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 9:57 PM
TimeFormat(now(),"medium"): 9:57:59 PM
TimeFormat(now(),"long"): 9:57:59 PM EST
TimeFormat(now(),"full"): 9:57:59 PM EST



Time: 09:57 PM