dateTimeFormat
Formats a datetime value using U.S. date and time formats. For international date support, use lsDateTimeFormat.
dateTimeFormat(date [, mask [, timezone]]) → returns string
Member Function Syntax
datetime.dateTimeFormat([mask [, timezone]])
Argument Reference
date date Required
datetime in Lucee. mask string
Default: dd-mmm-yyyy HH:nn:ss
dd-mmm-yyyy HH:nn:ss
short : equivalent to "m/d/y h:nn tt" - medium : equivalent to "mmm d, yyyy h:nn:ss tt" - long : medium with full month name rather than abbreviation, followed by three-letter time zone; as in, "mmmm d, yyyy h:mm:ss tt EST" - full : equivalent to "EEEE, mmmm d, yyyy h:mm:ss tt EST" - iso CF 2016+ Lucee 5.3.8+ Formats the date time in ISO8601 format - iso8601 Lucee 4.5+ Formats the date time in ISO8601 formatThe function also follows Java date time mask, except for mask "a". For more information, refer to Date and Time Patterns topic in SimpleDateFormat Java API page.JDK7 and JDK8 introduces the masks "w", "ww", "W", and "WW". timezone string
Default: System time-zone
System time-zone
Compatibility
ColdFusion:
Lucee:
Railo:
OpenBD:
Links more information about dateTimeFormat
- SimpleDateFormat - This function accepts the mask values documented here. **NOTE:** This is no longer followed after CF2016u3.
Examples Sample code invoking the dateTimeFormat function
On Lucee with Java 11 adds a comma after year bug: LDEV-3744
dateTimeFormat("2015-04-11 19:02", "short") Expected Result: 4/11/15 7:02 PM
On Lucee with Java 11 adds a comma after year bug: LDEV-3744
dateTimeFormat("2015-04-11 19:02", "medium") Expected Result: Apr 11, 2015 7:02:00 PM
On Lucee with Java 11 adds at before the time bug: LDEV-3744
dateTimeFormat("2015-04-11 19:02", "long") Expected Result: April 11, 2015 7:02:00 PM UTC
On Lucee with Java 11 adds at before the time bug: LDEV-3744
dateTimeFormat("2015-04-11 19:02", "full") Expected Result: Saturday, April 11, 2015 7:02:00 PM UTC
Uses the CF 2016+ iso or the Lucee 4.5+ iso8601 format depending on the engine. Note the depending on Java version the timezone format may differ (on Lucee at least, possible due to LDEV-3744)
dateTimeFormat("2015-04-11 19:02", (server.keyExists("lucee")) ? "iso8601" : "iso") Expected Result: 2015-04-11T19:02:00+0000
Simple date/time formatting using the member function syntax
createDateTime( 2022, 10, 1, 9, 30, 0 ).dateTimeFormat( 'mm/dd/yyyy hh:nn:ss tt' ) Expected Result: 10/01/2022 09:30:00 AM
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/datetimeformat