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



Time: 06:04 AM