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()): 24-May-18
DateFormat(now(),"mmm-dd-yyyy"):May-24-2018
 
DateFormat(now(),"m"): 5
DateFormat(now(),"mm"): 05
DateFormat(now(),"mmm"): May
DateFormat(now(),"mmmm"): May
 
DateFormat(now(),"d"): 24
DateFormat(now(),"dd"): 24
DateFormat(now(),"ddd"): Thu
DateFormat(now(),"dddd"): Thursday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 5/24/18
DateFormat(now(),"medium"): May 24, 2018
DateFormat(now(),"long"): May 24, 2018
DateFormat(now(),"full"): Thursday, May 24, 2018
 
TimeFormat(now()): 04:57 PM
TimeFormat(now(),"hh:mm:ss t"):04:57:47 P
TimeFormat(now(),"hh:mm:ss tt"):04:57:47 PM
12 hour format
TimeFormat(now(),"h"): 4
TimeFormat(now(),"hh"): 04
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 16
TimeFormat(now(),"HH"): 16
 
TimeFormat(now(),"m"): 57
TimeFormat(now(),"mm"): 57
 
TimeFormat(now(),"s"): 47
TimeFormat(now(),"ss"): 47
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 4:57 PM
TimeFormat(now(),"medium"): 4:57:47 PM
TimeFormat(now(),"long"): 4:57:47 PM EDT
TimeFormat(now(),"full"): 4:57:47 PM EDT



Time: 04:57 PM