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()): 29-Apr-17
DateFormat(now(),"mmm-dd-yyyy"):Apr-29-2017
 
DateFormat(now(),"m"): 4
DateFormat(now(),"mm"): 04
DateFormat(now(),"mmm"): Apr
DateFormat(now(),"mmmm"): April
 
DateFormat(now(),"d"): 29
DateFormat(now(),"dd"): 29
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 17
DateFormat(now(),"yy"): 17
DateFormat(now(),"yyyy"): 2017
 
DateFormat(now(),"short"): 4/29/17
DateFormat(now(),"medium"): Apr 29, 2017
DateFormat(now(),"long"): April 29, 2017
DateFormat(now(),"full"): Saturday, April 29, 2017
 
TimeFormat(now()): 07:26 AM
TimeFormat(now(),"hh:mm:ss t"):07:26:24 A
TimeFormat(now(),"hh:mm:ss tt"):07:26:24 AM
12 hour format
TimeFormat(now(),"h"): 7
TimeFormat(now(),"hh"): 07
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 7
TimeFormat(now(),"HH"): 07
 
TimeFormat(now(),"m"): 26
TimeFormat(now(),"mm"): 26
 
TimeFormat(now(),"s"): 24
TimeFormat(now(),"ss"): 24
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 7:26 AM
TimeFormat(now(),"medium"): 7:26:24 AM
TimeFormat(now(),"long"): 7:26:24 AM EDT
TimeFormat(now(),"full"): 7:26:24 AM EDT



Time: 07:26 AM