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()): 18-Jun-18
DateFormat(now(),"mmm-dd-yyyy"):Jun-18-2018
 
DateFormat(now(),"m"): 6
DateFormat(now(),"mm"): 06
DateFormat(now(),"mmm"): Jun
DateFormat(now(),"mmmm"): June
 
DateFormat(now(),"d"): 18
DateFormat(now(),"dd"): 18
DateFormat(now(),"ddd"): Mon
DateFormat(now(),"dddd"): Monday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 6/18/18
DateFormat(now(),"medium"): Jun 18, 2018
DateFormat(now(),"long"): June 18, 2018
DateFormat(now(),"full"): Monday, June 18, 2018
 
TimeFormat(now()): 05:51 AM
TimeFormat(now(),"hh:mm:ss t"):05:51:42 A
TimeFormat(now(),"hh:mm:ss tt"):05:51:42 AM
12 hour format
TimeFormat(now(),"h"): 5
TimeFormat(now(),"hh"): 05
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 5
TimeFormat(now(),"HH"): 05
 
TimeFormat(now(),"m"): 51
TimeFormat(now(),"mm"): 51
 
TimeFormat(now(),"s"): 42
TimeFormat(now(),"ss"): 42
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 5:51 AM
TimeFormat(now(),"medium"): 5:51:42 AM
TimeFormat(now(),"long"): 5:51:42 AM EDT
TimeFormat(now(),"full"): 5:51:42 AM EDT



Time: 05:51 AM