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()): 21-Feb-19
DateFormat(now(),"mmm-dd-yyyy"):Feb-21-2019
 
DateFormat(now(),"m"): 2
DateFormat(now(),"mm"): 02
DateFormat(now(),"mmm"): Feb
DateFormat(now(),"mmmm"): February
 
DateFormat(now(),"d"): 21
DateFormat(now(),"dd"): 21
DateFormat(now(),"ddd"): Thu
DateFormat(now(),"dddd"): Thursday
 
DateFormat(now(),"y"): 19
DateFormat(now(),"yy"): 19
DateFormat(now(),"yyyy"): 2019
 
DateFormat(now(),"short"): 2/21/19
DateFormat(now(),"medium"): Feb 21, 2019
DateFormat(now(),"long"): February 21, 2019
DateFormat(now(),"full"): Thursday, February 21, 2019
 
TimeFormat(now()): 06:04 PM
TimeFormat(now(),"hh:mm:ss t"):06:04:31 P
TimeFormat(now(),"hh:mm:ss tt"):06:04:31 PM
12 hour format
TimeFormat(now(),"h"): 6
TimeFormat(now(),"hh"): 06
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 18
TimeFormat(now(),"HH"): 18
 
TimeFormat(now(),"m"): 4
TimeFormat(now(),"mm"): 04
 
TimeFormat(now(),"s"): 31
TimeFormat(now(),"ss"): 31
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 6:04 PM
TimeFormat(now(),"medium"): 6:04:31 PM
TimeFormat(now(),"long"): 6:04:31 PM EST
TimeFormat(now(),"full"): 6:04:31 PM EST



Time: 06:04 PM