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()): 18-Sep-21
DateFormat(now(),"mmm-dd-yyyy"):Sep-18-2021
 
DateFormat(now(),"m"): 9
DateFormat(now(),"mm"): 09
DateFormat(now(),"mmm"): Sep
DateFormat(now(),"mmmm"): September
 
DateFormat(now(),"d"): 18
DateFormat(now(),"dd"): 18
DateFormat(now(),"ddd"): Sat
DateFormat(now(),"dddd"): Saturday
 
DateFormat(now(),"y"): 2021
DateFormat(now(),"yy"): 21
DateFormat(now(),"yyyy"): 2021
 
DateFormat(now(),"short"): 9/18/21
DateFormat(now(),"medium"): Sep 18, 2021
DateFormat(now(),"long"): September 18, 2021
DateFormat(now(),"full"): Saturday, September 18, 2021
 
TimeFormat(now()): 04:32 AM
TimeFormat(now(),"hh:mm:ss t"):04:32:29 A
TimeFormat(now(),"hh:mm:ss tt"):04:32:29 AM
12 hour format
TimeFormat(now(),"h"): 4
TimeFormat(now(),"hh"): 04
24 hour format 00:00 to 23:00
TimeFormat(now(),"H"): 4
TimeFormat(now(),"HH"): 04
 
TimeFormat(now(),"m"): 32
TimeFormat(now(),"mm"): 32
 
TimeFormat(now(),"s"): 29
TimeFormat(now(),"ss"): 29
 
TimeFormat(now(),"1"): 1
 
TimeFormat(now(),"t"): A
TimeFormat(now(),"tt"): AM
 
TimeFormat(now(),"short"): 4:32 AM
TimeFormat(now(),"medium"): 4:32:29 AM
TimeFormat(now(),"long"): 4:32:29 AM EDT
TimeFormat(now(),"full"): 4:32:29 AM EDT



Time: 04:32 AM


Debugging Information
ColdFusion Server Enterprise 2021,0,0,323925
Template /CF_DOCS/DateTimeFormat.cfm
Time Stamp 18-Sep-21 04:32 AM
Locale English (US)
User Agent CCBot/2.0 (https://commoncrawl.org/faq/)
Remote IP 34.239.177.24
Host Name 34.239.177.24


Execution Time

Total Time Avg Time Count Template
16 ms 16 ms 1 top level D:\Websites\bcra-mlscom\mmcctech\CF_DOCS\DateTimeFormat.cfm
0 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=34.239.177.24
REMOTE_HOST=34.239.177.24
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