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()): 19-Aug-22
DateFormat(now(),"mmm-dd-yyyy"):Aug-19-2022
 
DateFormat(now(),"m"): 8
DateFormat(now(),"mm"): 08
DateFormat(now(),"mmm"): Aug
DateFormat(now(),"mmmm"): August
 
DateFormat(now(),"d"): 19
DateFormat(now(),"dd"): 19
DateFormat(now(),"ddd"): Fri
DateFormat(now(),"dddd"): Friday
 
DateFormat(now(),"y"): 2022
DateFormat(now(),"yy"): 22
DateFormat(now(),"yyyy"): 2022
 
DateFormat(now(),"short"): 8/19/22
DateFormat(now(),"medium"): Aug 19, 2022
DateFormat(now(),"long"): August 19, 2022
DateFormat(now(),"full"): Friday, August 19, 2022
 
TimeFormat(now()): 02:15 PM
TimeFormat(now(),"hh:mm:ss t"):02:15:52 P
TimeFormat(now(),"hh:mm:ss tt"):02:15:52 PM
12 hour format
TimeFormat(now(),"h"): 2
TimeFormat(now(),"hh"): 02
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 14
TimeFormat(now(),"HH"): 14
 
TimeFormat(now(),"m"): 15
TimeFormat(now(),"mm"): 15
 
TimeFormat(now(),"s"): 52
TimeFormat(now(),"ss"): 52
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 2:15 PM
TimeFormat(now(),"medium"): 2:15:52 PM
TimeFormat(now(),"long"): 2:15:52 PM EDT
TimeFormat(now(),"full"): 2:15:52 PM EDT



Time: 02:15 PM