Formats a datetime value using U.S. date and time formats. For international date support, use lsDateTimeFormat.
dateTimeFormat(date [, mask [, timezone]])
→ returns string
datetime.dateTimeFormat([mask [, timezone]])
datetime
in Lucee.
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 formatiso8601
Lucee 4.5+ Formats the date time in ISO8601 formatSimpleDateFormat
Java API page.System time-zone
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
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.