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()): 16-Jul-18
DateFormat(now(),"mmm-dd-yyyy"):Jul-16-2018
 
DateFormat(now(),"m"): 7
DateFormat(now(),"mm"): 07
DateFormat(now(),"mmm"): Jul
DateFormat(now(),"mmmm"): July
 
DateFormat(now(),"d"): 16
DateFormat(now(),"dd"): 16
DateFormat(now(),"ddd"): Mon
DateFormat(now(),"dddd"): Monday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 7/16/18
DateFormat(now(),"medium"): Jul 16, 2018
DateFormat(now(),"long"): July 16, 2018
DateFormat(now(),"full"): Monday, July 16, 2018
 
TimeFormat(now()): 10:38 AM
TimeFormat(now(),"hh:mm:ss t"):10:38:01 A
TimeFormat(now(),"hh:mm:ss tt"):10:38:01 AM
12 hour format
TimeFormat(now(),"h"): 10
TimeFormat(now(),"hh"): 10
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 10
TimeFormat(now(),"HH"): 10
 
TimeFormat(now(),"m"): 38
TimeFormat(now(),"mm"): 38
 
TimeFormat(now(),"s"): 1
TimeFormat(now(),"ss"): 01
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 10:38 AM
TimeFormat(now(),"medium"): 10:38:01 AM
TimeFormat(now(),"long"): 10:38:01 AM EDT
TimeFormat(now(),"full"): 10:38:01 AM EDT



Time: 10:38 AM