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-17
DateFormat(now(),"mmm-dd-yyyy"):Nov-21-2017
 
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"): Tue
DateFormat(now(),"dddd"): Tuesday
 
DateFormat(now(),"y"): 17
DateFormat(now(),"yy"): 17
DateFormat(now(),"yyyy"): 2017
 
DateFormat(now(),"short"): 11/21/17
DateFormat(now(),"medium"): Nov 21, 2017
DateFormat(now(),"long"): November 21, 2017
DateFormat(now(),"full"): Tuesday, November 21, 2017
 
TimeFormat(now()): 01:56 PM
TimeFormat(now(),"hh:mm:ss t"):01:56:56 P
TimeFormat(now(),"hh:mm:ss tt"):01:56:56 PM
12 hour format
TimeFormat(now(),"h"): 1
TimeFormat(now(),"hh"): 01
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 13
TimeFormat(now(),"HH"): 13
 
TimeFormat(now(),"m"): 56
TimeFormat(now(),"mm"): 56
 
TimeFormat(now(),"s"): 56
TimeFormat(now(),"ss"): 56
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 1:56 PM
TimeFormat(now(),"medium"): 1:56:56 PM
TimeFormat(now(),"long"): 1:56:56 PM EST
TimeFormat(now(),"full"): 1:56:56 PM EST



Time: 01:56 PM