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()): 05-Jul-20
DateFormat(now(),"mmm-dd-yyyy"):Jul-05-2020
 
DateFormat(now(),"m"): 7
DateFormat(now(),"mm"): 07
DateFormat(now(),"mmm"): Jul
DateFormat(now(),"mmmm"): July
 
DateFormat(now(),"d"): 5
DateFormat(now(),"dd"): 05
DateFormat(now(),"ddd"): Sun
DateFormat(now(),"dddd"): Sunday
 
DateFormat(now(),"y"): 20
DateFormat(now(),"yy"): 20
DateFormat(now(),"yyyy"): 2020
 
DateFormat(now(),"short"): 7/5/20
DateFormat(now(),"medium"): Jul 5, 2020
DateFormat(now(),"long"): July 5, 2020
DateFormat(now(),"full"): Sunday, July 5, 2020
 
TimeFormat(now()): 03:33 PM
TimeFormat(now(),"hh:mm:ss t"):03:33:50 P
TimeFormat(now(),"hh:mm:ss tt"):03:33:50 PM
12 hour format
TimeFormat(now(),"h"): 3
TimeFormat(now(),"hh"): 03
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 15
TimeFormat(now(),"HH"): 15
 
TimeFormat(now(),"m"): 33
TimeFormat(now(),"mm"): 33
 
TimeFormat(now(),"s"): 50
TimeFormat(now(),"ss"): 50
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 3:33 PM
TimeFormat(now(),"medium"): 3:33:50 PM
TimeFormat(now(),"long"): 3:33:50 PM EDT
TimeFormat(now(),"full"): 3:33:50 PM EDT



Time: 03:33 PM