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()): 02-Aug-21
DateFormat(now(),"mmm-dd-yyyy"):Aug-02-2021
 
DateFormat(now(),"m"): 8
DateFormat(now(),"mm"): 08
DateFormat(now(),"mmm"): Aug
DateFormat(now(),"mmmm"): August
 
DateFormat(now(),"d"): 2
DateFormat(now(),"dd"): 02
DateFormat(now(),"ddd"): Mon
DateFormat(now(),"dddd"): Monday
 
DateFormat(now(),"y"): 2021
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 8/2/21
DateFormat(now(),"medium"): Aug 2, 2021
DateFormat(now(),"long"): August 2, 2021
DateFormat(now(),"full"): Monday, August 2, 2021
 
TimeFormat(now()): 10:05 PM
TimeFormat(now(),"hh:mm:ss t"):10:05:05 P
TimeFormat(now(),"hh:mm:ss tt"):10:05:05 PM
12 hour format
TimeFormat(now(),"h"): 10
TimeFormat(now(),"hh"): 10
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 22
TimeFormat(now(),"HH"): 22
 
TimeFormat(now(),"m"): 5
TimeFormat(now(),"mm"): 05
 
TimeFormat(now(),"s"): 5
TimeFormat(now(),"ss"): 05
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): P
TimeFormat(now(),"tt"): PM
 
TimeFormat(now(),"short"): 10:05 PM
TimeFormat(now(),"medium"): 10:05:05 PM
TimeFormat(now(),"long"): 10:05:05 PM EDT
TimeFormat(now(),"full"): 10:05:05 PM EDT



Time: 10:05 PM


Debugging Information
ColdFusion Server Enterprise 2021,0,0,323925
Template /CF_DOCS/DateTimeFormat.cfm
Time Stamp 02-Aug-21 10:05 PM
Locale English (US)
User Agent CCBot/2.0 (https://commoncrawl.org/faq/)
Remote IP 3.231.230.177
Host Name 3.231.230.177


Execution Time

Total Time Avg Time Count Template
0 ms 0 ms 1 top level D:\Websites\bcra-mlscom\mmcctech\CF_DOCS\DateTimeFormat.cfm
16 ms  STARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN
16 ms  TOTAL EXECUTION TIME
red = over 250 ms average execution time


Scope Variables

CGI Variables:
AUTH_PASSWORD=
AUTH_TYPE=
AUTH_USER=
CERT_COOKIE=
CERT_FLAGS=
CERT_ISSUER=
CERT_KEYSIZE=
CERT_SECRETKEYSIZE=
CERT_SERIALNUMBER=
CERT_SERVER_ISSUER=
CERT_SERVER_SUBJECT=
CERT_SUBJECT=
CF_TEMPLATE_PATH=D:\Websites\bcra-mlscom\mmcctech\CF_DOCS\DateTimeFormat.cfm
CONTENT_LENGTH=0
CONTENT_TYPE=
CONTEXT_PATH=
GATEWAY_INTERFACE=CGI/1.1
HTTPS=off
HTTPS_KEYSIZE=
HTTPS_SECRETKEYSIZE=
HTTPS_SERVER_ISSUER=
HTTPS_SERVER_SUBJECT=
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODING=br,gzip
HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.5
HTTP_CONNECTION=Keep-Alive
HTTP_COOKIE=
HTTP_HOST=mmcctech.com
HTTP_REFERER=
HTTP_URL=/CF_DOCS/DateTimeFormat.cfm
HTTP_USER_AGENT=CCBot/2.0 (https://commoncrawl.org/faq/)
LOCAL_ADDR=192.168.162.152
PATH_INFO=
PATH_TRANSLATED=D:\Websites\bcra-mlscom\mmcctech\CF_DOCS\DateTimeFormat.cfm
QUERY_STRING=
REMOTE_ADDR=3.231.230.177
REMOTE_HOST=3.231.230.177
REMOTE_USER=
REQUEST_METHOD=GET
SCRIPT_NAME=/CF_DOCS/DateTimeFormat.cfm
SERVER_NAME=mmcctech.com
SERVER_PORT=80
SERVER_PORT_SECURE=0
SERVER_PROTOCOL=HTTP/1.1
SERVER_SOFTWARE=Microsoft-IIS/10.0
WEB_SERVER_API=
Debug Rendering Time: 0 ms