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()): 02-Mar-24
DateFormat(now(),"mmm-dd-yyyy"):Mar-02-2024
 
DateFormat(now(),"m"): 3
DateFormat(now(),"mm"): 03
DateFormat(now(),"mmm"): Mar
DateFormat(now(),"mmmm"): March
 
DateFormat(now(),"d"): 2
DateFormat(now(),"dd"): 02
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 2024
DateFormat(now(),"yy"): 24
DateFormat(now(),"yyyy"): 2024
 
DateFormat(now(),"short"): 3/2/24
DateFormat(now(),"medium"): Mar 2, 2024
DateFormat(now(),"long"): March 2, 2024
DateFormat(now(),"full"): Saturday, March 2, 2024
 
TimeFormat(now()): 09:25 AM
TimeFormat(now(),"hh:mm:ss t"):09:25:30 A
TimeFormat(now(),"hh:mm:ss tt"):09:25:30 AM
12 hour format
TimeFormat(now(),"h"): 9
TimeFormat(now(),"hh"): 09
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 9
TimeFormat(now(),"HH"): 09
 
TimeFormat(now(),"m"): 25
TimeFormat(now(),"mm"): 25
 
TimeFormat(now(),"s"): 30
TimeFormat(now(),"ss"): 30
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 9:25 AM
TimeFormat(now(),"medium"): 9:25:30 AM
TimeFormat(now(),"long"): 9:25:30 AM EST
TimeFormat(now(),"full"): 9:25:30 AM EST



Time: 09:25 AM