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-Apr-20
DateFormat(now(),"mmm-dd-yyyy"):Apr-08-2020
 
DateFormat(now(),"m"): 4
DateFormat(now(),"mm"): 04
DateFormat(now(),"mmm"): Apr
DateFormat(now(),"mmmm"): April
 
DateFormat(now(),"d"): 8
DateFormat(now(),"dd"): 08
DateFormat(now(),"ddd"): Wed
DateFormat(now(),"dddd"): Wednesday
 
DateFormat(now(),"y"): 20
DateFormat(now(),"yy"): 20
DateFormat(now(),"yyyy"): 2020
 
DateFormat(now(),"short"): 4/8/20
DateFormat(now(),"medium"): Apr 8, 2020
DateFormat(now(),"long"): April 8, 2020
DateFormat(now(),"full"): Wednesday, April 8, 2020
 
TimeFormat(now()): 03:34 PM
TimeFormat(now(),"hh:mm:ss t"):03:34:59 P
TimeFormat(now(),"hh:mm:ss tt"):03:34:59 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"): 34
TimeFormat(now(),"mm"): 34
 
TimeFormat(now(),"s"): 59
TimeFormat(now(),"ss"): 59
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 3:34 PM
TimeFormat(now(),"medium"): 3:34:59 PM
TimeFormat(now(),"long"): 3:34:59 PM EDT
TimeFormat(now(),"full"): 3:34:59 PM EDT



Time: 03:34 PM