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()): 23-Sep-17
DateFormat(now(),"mmm-dd-yyyy"):Sep-23-2017
 
DateFormat(now(),"m"): 9
DateFormat(now(),"mm"): 09
DateFormat(now(),"mmm"): Sep
DateFormat(now(),"mmmm"): September
 
DateFormat(now(),"d"): 23
DateFormat(now(),"dd"): 23
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 17
DateFormat(now(),"yy"): 17
DateFormat(now(),"yyyy"): 2017
 
DateFormat(now(),"short"): 9/23/17
DateFormat(now(),"medium"): Sep 23, 2017
DateFormat(now(),"long"): September 23, 2017
DateFormat(now(),"full"): Saturday, September 23, 2017
 
TimeFormat(now()): 02:10 PM
TimeFormat(now(),"hh:mm:ss t"):02:10:21 P
TimeFormat(now(),"hh:mm:ss tt"):02:10:21 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"): 10
TimeFormat(now(),"mm"): 10
 
TimeFormat(now(),"s"): 21
TimeFormat(now(),"ss"): 21
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 2:10 PM
TimeFormat(now(),"medium"): 2:10:21 PM
TimeFormat(now(),"long"): 2:10:21 PM EDT
TimeFormat(now(),"full"): 2:10:21 PM EDT



Time: 02:10 PM