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()): 22-May-18
DateFormat(now(),"mmm-dd-yyyy"):May-22-2018
 
DateFormat(now(),"m"): 5
DateFormat(now(),"mm"): 05
DateFormat(now(),"mmm"): May
DateFormat(now(),"mmmm"): May
 
DateFormat(now(),"d"): 22
DateFormat(now(),"dd"): 22
DateFormat(now(),"ddd"): Tue
DateFormat(now(),"dddd"): Tuesday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 5/22/18
DateFormat(now(),"medium"): May 22, 2018
DateFormat(now(),"long"): May 22, 2018
DateFormat(now(),"full"): Tuesday, May 22, 2018
 
TimeFormat(now()): 01:59 AM
TimeFormat(now(),"hh:mm:ss t"):01:59:30 A
TimeFormat(now(),"hh:mm:ss tt"):01:59:30 AM
12 hour format
TimeFormat(now(),"h"): 1
TimeFormat(now(),"hh"): 01
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 1
TimeFormat(now(),"HH"): 01
 
TimeFormat(now(),"m"): 59
TimeFormat(now(),"mm"): 59
 
TimeFormat(now(),"s"): 30
TimeFormat(now(),"ss"): 30
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 1:59 AM
TimeFormat(now(),"medium"): 1:59:30 AM
TimeFormat(now(),"long"): 1:59:30 AM EDT
TimeFormat(now(),"full"): 1:59:30 AM EDT



Time: 01:59 AM