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()): 26-Jul-17
DateFormat(now(),"mmm-dd-yyyy"):Jul-26-2017
 
DateFormat(now(),"m"): 7
DateFormat(now(),"mm"): 07
DateFormat(now(),"mmm"): Jul
DateFormat(now(),"mmmm"): July
 
DateFormat(now(),"d"): 26
DateFormat(now(),"dd"): 26
DateFormat(now(),"ddd"): Wed
DateFormat(now(),"dddd"): Wednesday
 
DateFormat(now(),"y"): 17
DateFormat(now(),"yy"): 17
DateFormat(now(),"yyyy"): 2017
 
DateFormat(now(),"short"): 7/26/17
DateFormat(now(),"medium"): Jul 26, 2017
DateFormat(now(),"long"): July 26, 2017
DateFormat(now(),"full"): Wednesday, July 26, 2017
 
TimeFormat(now()): 10:32 PM
TimeFormat(now(),"hh:mm:ss t"):10:32:16 P
TimeFormat(now(),"hh:mm:ss tt"):10:32:16 PM
12 hour format
TimeFormat(now(),"h"): 10
TimeFormat(now(),"hh"): 10
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 22
TimeFormat(now(),"HH"): 22
 
TimeFormat(now(),"m"): 32
TimeFormat(now(),"mm"): 32
 
TimeFormat(now(),"s"): 16
TimeFormat(now(),"ss"): 16
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 10:32 PM
TimeFormat(now(),"medium"): 10:32:16 PM
TimeFormat(now(),"long"): 10:32:16 PM EDT
TimeFormat(now(),"full"): 10:32:16 PM EDT



Time: 10:32 PM