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()): 14-Jun-21
DateFormat(now(),"mmm-dd-yyyy"):Jun-14-2021
 
DateFormat(now(),"m"): 6
DateFormat(now(),"mm"): 06
DateFormat(now(),"mmm"): Jun
DateFormat(now(),"mmmm"): June
 
DateFormat(now(),"d"): 14
DateFormat(now(),"dd"): 14
DateFormat(now(),"ddd"): Mon
DateFormat(now(),"dddd"): Monday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 6/14/21
DateFormat(now(),"medium"): Jun 14, 2021
DateFormat(now(),"long"): June 14, 2021
DateFormat(now(),"full"): Monday, June 14, 2021
 
TimeFormat(now()): 07:32 AM
TimeFormat(now(),"hh:mm:ss t"):07:32:46 A
TimeFormat(now(),"hh:mm:ss tt"):07:32:46 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"): 32
TimeFormat(now(),"mm"): 32
 
TimeFormat(now(),"s"): 46
TimeFormat(now(),"ss"): 46
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 7:32 AM
TimeFormat(now(),"medium"): 7:32:46 AM
TimeFormat(now(),"long"): 7:32:46 AM EDT
TimeFormat(now(),"full"): 7:32:46 AM EDT



Time: 07:32 AM