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



Time: 06:30 PM