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-Aug-20
DateFormat(now(),"mmm-dd-yyyy"):Aug-09-2020
 
DateFormat(now(),"m"): 8
DateFormat(now(),"mm"): 08
DateFormat(now(),"mmm"): Aug
DateFormat(now(),"mmmm"): August
 
DateFormat(now(),"d"): 9
DateFormat(now(),"dd"): 09
DateFormat(now(),"ddd"): Sun
DateFormat(now(),"dddd"): Sunday
 
DateFormat(now(),"y"): 20
DateFormat(now(),"yy"): 20
DateFormat(now(),"yyyy"): 2020
 
DateFormat(now(),"short"): 8/9/20
DateFormat(now(),"medium"): Aug 9, 2020
DateFormat(now(),"long"): August 9, 2020
DateFormat(now(),"full"): Sunday, August 9, 2020
 
TimeFormat(now()): 09:52 PM
TimeFormat(now(),"hh:mm:ss t"):09:52:37 P
TimeFormat(now(),"hh:mm:ss tt"):09:52:37 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"): 52
TimeFormat(now(),"mm"): 52
 
TimeFormat(now(),"s"): 37
TimeFormat(now(),"ss"): 37
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 9:52 PM
TimeFormat(now(),"medium"): 9:52:37 PM
TimeFormat(now(),"long"): 9:52:37 PM EDT
TimeFormat(now(),"full"): 9:52:37 PM EDT



Time: 09:52 PM