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()): 16-Jan-21
DateFormat(now(),"mmm-dd-yyyy"):Jan-16-2021
 
DateFormat(now(),"m"): 1
DateFormat(now(),"mm"): 01
DateFormat(now(),"mmm"): Jan
DateFormat(now(),"mmmm"): January
 
DateFormat(now(),"d"): 16
DateFormat(now(),"dd"): 16
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 21
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 1/16/21
DateFormat(now(),"medium"): Jan 16, 2021
DateFormat(now(),"long"): January 16, 2021
DateFormat(now(),"full"): Saturday, January 16, 2021
 
TimeFormat(now()): 03:38 PM
TimeFormat(now(),"hh:mm:ss t"):03:38:46 P
TimeFormat(now(),"hh:mm:ss tt"):03:38:46 PM
12 hour format
TimeFormat(now(),"h"): 3
TimeFormat(now(),"hh"): 03
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 15
TimeFormat(now(),"HH"): 15
 
TimeFormat(now(),"m"): 38
TimeFormat(now(),"mm"): 38
 
TimeFormat(now(),"s"): 46
TimeFormat(now(),"ss"): 46
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 3:38 PM
TimeFormat(now(),"medium"): 3:38:46 PM
TimeFormat(now(),"long"): 3:38:46 PM EST
TimeFormat(now(),"full"): 3:38:46 PM EST



Time: 03:38 PM