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()): 09-May-21
DateFormat(now(),"mmm-dd-yyyy"):May-09-2021
 
DateFormat(now(),"m"): 5
DateFormat(now(),"mm"): 05
DateFormat(now(),"mmm"): May
DateFormat(now(),"mmmm"): May
 
DateFormat(now(),"d"): 9
DateFormat(now(),"dd"): 09
DateFormat(now(),"ddd"): Sun
DateFormat(now(),"dddd"): Sunday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 5/9/21
DateFormat(now(),"medium"): May 9, 2021
DateFormat(now(),"long"): May 9, 2021
DateFormat(now(),"full"): Sunday, May 9, 2021
 
TimeFormat(now()): 09:27 PM
TimeFormat(now(),"hh:mm:ss t"):09:27:07 P
TimeFormat(now(),"hh:mm:ss tt"):09:27:07 PM
12 hour format
TimeFormat(now(),"h"): 9
TimeFormat(now(),"hh"): 09
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 21
TimeFormat(now(),"HH"): 21
 
TimeFormat(now(),"m"): 27
TimeFormat(now(),"mm"): 27
 
TimeFormat(now(),"s"): 7
TimeFormat(now(),"ss"): 07
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 9:27 PM
TimeFormat(now(),"medium"): 9:27:07 PM
TimeFormat(now(),"long"): 9:27:07 PM EDT
TimeFormat(now(),"full"): 9:27:07 PM EDT



Time: 09:27 PM