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



Time: 12:31 AM