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()): 07-Feb-23
DateFormat(now(),"mmm-dd-yyyy"):Feb-07-2023
 
DateFormat(now(),"m"): 2
DateFormat(now(),"mm"): 02
DateFormat(now(),"mmm"): Feb
DateFormat(now(),"mmmm"): February
 
DateFormat(now(),"d"): 7
DateFormat(now(),"dd"): 07
DateFormat(now(),"ddd"): Tue
DateFormat(now(),"dddd"): Tuesday
 
DateFormat(now(),"y"): 2023
DateFormat(now(),"yy"): 23
DateFormat(now(),"yyyy"): 2023
 
DateFormat(now(),"short"): 2/7/23
DateFormat(now(),"medium"): Feb 7, 2023
DateFormat(now(),"long"): February 7, 2023
DateFormat(now(),"full"): Tuesday, February 7, 2023
 
TimeFormat(now()): 02:09 PM
TimeFormat(now(),"hh:mm:ss t"):02:09:25 P
TimeFormat(now(),"hh:mm:ss tt"):02:09:25 PM
12 hour format
TimeFormat(now(),"h"): 2
TimeFormat(now(),"hh"): 02
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 14
TimeFormat(now(),"HH"): 14
 
TimeFormat(now(),"m"): 9
TimeFormat(now(),"mm"): 09
 
TimeFormat(now(),"s"): 25
TimeFormat(now(),"ss"): 25
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 2:09 PM
TimeFormat(now(),"medium"): 2:09:25 PM
TimeFormat(now(),"long"): 2:09:25 PM EST
TimeFormat(now(),"full"): 2:09:25 PM EST



Time: 02:09 PM