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()): 09:27 PM
TimeFormat(now(),"hh:mm:ss t"):09:27:24 P
TimeFormat(now(),"hh:mm:ss tt"):09:27:24 PM
12 hour format
TimeFormat(now(),"h"): 9
TimeFormat(now(),"hh"): 09
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 21
TimeFormat(now(),"HH"): 21
 
TimeFormat(now(),"m"): 27
TimeFormat(now(),"mm"): 27
 
TimeFormat(now(),"s"): 24
TimeFormat(now(),"ss"): 24
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 9:27 PM
TimeFormat(now(),"medium"): 9:27:24 PM
TimeFormat(now(),"long"): 9:27:24 PM EDT
TimeFormat(now(),"full"): 9:27:24 PM EDT



Time: 09:27 PM