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()): 20-Jan-18
DateFormat(now(),"mmm-dd-yyyy"):Jan-20-2018
 
DateFormat(now(),"m"): 1
DateFormat(now(),"mm"): 01
DateFormat(now(),"mmm"): Jan
DateFormat(now(),"mmmm"): January
 
DateFormat(now(),"d"): 20
DateFormat(now(),"dd"): 20
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 1/20/18
DateFormat(now(),"medium"): Jan 20, 2018
DateFormat(now(),"long"): January 20, 2018
DateFormat(now(),"full"): Saturday, January 20, 2018
 
TimeFormat(now()): 09:42 PM
TimeFormat(now(),"hh:mm:ss t"):09:42:48 P
TimeFormat(now(),"hh:mm:ss tt"):09:42:48 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"): 42
TimeFormat(now(),"mm"): 42
 
TimeFormat(now(),"s"): 48
TimeFormat(now(),"ss"): 48
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 9:42 PM
TimeFormat(now(),"medium"): 9:42:48 PM
TimeFormat(now(),"long"): 9:42:48 PM EST
TimeFormat(now(),"full"): 9:42:48 PM EST



Time: 09:42 PM