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



Time: 12:01 PM