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()): 22-Jan-18
DateFormat(now(),"mmm-dd-yyyy"):Jan-22-2018
 
DateFormat(now(),"m"): 1
DateFormat(now(),"mm"): 01
DateFormat(now(),"mmm"): Jan
DateFormat(now(),"mmmm"): January
 
DateFormat(now(),"d"): 22
DateFormat(now(),"dd"): 22
DateFormat(now(),"ddd"): Mon
DateFormat(now(),"dddd"): Monday
 
DateFormat(now(),"y"): 18
DateFormat(now(),"yy"): 18
DateFormat(now(),"yyyy"): 2018
 
DateFormat(now(),"short"): 1/22/18
DateFormat(now(),"medium"): Jan 22, 2018
DateFormat(now(),"long"): January 22, 2018
DateFormat(now(),"full"): Monday, January 22, 2018
 
TimeFormat(now()): 07:06 PM
TimeFormat(now(),"hh:mm:ss t"):07:06:39 P
TimeFormat(now(),"hh:mm:ss tt"):07:06:39 PM
12 hour format
TimeFormat(now(),"h"): 7
TimeFormat(now(),"hh"): 07
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 19
TimeFormat(now(),"HH"): 19
 
TimeFormat(now(),"m"): 6
TimeFormat(now(),"mm"): 06
 
TimeFormat(now(),"s"): 39
TimeFormat(now(),"ss"): 39
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 7:06 PM
TimeFormat(now(),"medium"): 7:06:39 PM
TimeFormat(now(),"long"): 7:06:39 PM EST
TimeFormat(now(),"full"): 7:06:39 PM EST



Time: 07:06 PM