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()): 08-Mar-21
DateFormat(now(),"mmm-dd-yyyy"):Mar-08-2021
 
DateFormat(now(),"m"): 3
DateFormat(now(),"mm"): 03
DateFormat(now(),"mmm"): Mar
DateFormat(now(),"mmmm"): March
 
DateFormat(now(),"d"): 8
DateFormat(now(),"dd"): 08
DateFormat(now(),"ddd"): Mon
DateFormat(now(),"dddd"): Monday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 3/8/21
DateFormat(now(),"medium"): Mar 8, 2021
DateFormat(now(),"long"): March 8, 2021
DateFormat(now(),"full"): Monday, March 8, 2021
 
TimeFormat(now()): 11:59 AM
TimeFormat(now(),"hh:mm:ss t"):11:59:16 A
TimeFormat(now(),"hh:mm:ss tt"):11:59:16 AM
12 hour format
TimeFormat(now(),"h"): 11
TimeFormat(now(),"hh"): 11
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 11
TimeFormat(now(),"HH"): 11
 
TimeFormat(now(),"m"): 59
TimeFormat(now(),"mm"): 59
 
TimeFormat(now(),"s"): 16
TimeFormat(now(),"ss"): 16
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 11:59 AM
TimeFormat(now(),"medium"): 11:59:16 AM
TimeFormat(now(),"long"): 11:59:16 AM EST
TimeFormat(now(),"full"): 11:59:16 AM EST



Time: 11:59 AM