dateTimeFormat

Formats a datetime value using U.S. date and time formats. For international date support, use LSDateTimeFormat.
[mask - quicky]
d: Day of the month as digits; no leading zero for single-digit days.
dd: Day of the month as digits; leading zero for single-digit days.
EEE: Day of the week as a three-letter abbreviation.
EEEE: Day of the week as its full name.
m: Month as digits; no leading zero for single-digit months.
mm: Month as digits; leading zero for single-digit months.
mmm: Month as a three-letter abbreviation.
mmmm: Month as its full name.
yy: Year as last two digits; leading zero for years less than 10.
yyyy: Year represented by four digits.
Y YY: Week Year
G: Period/era string.
h: hours; no leading zero for single-digit hours (12-hour clock)
hh: hours; leading zero for single-digit hours (12-hour clock)
H: hours; no leading zero for single-digit hours (24-hour clock)
HH: hours; leading zero for single-digit hours (24-hour clock)
n: minutes; no leading zero for single-digit minutes
nn: minutes; a leading zero for single-digit minutes
s: seconds; no leading zero for single-digit seconds
ss: seconds; leading zero for single-digit seconds
l or L: milliseconds, with no leading zeros
t: one-character time marker string, such as A or P
tt: multiple-character time marker string, such as AM or PM

dateTimeFormat(dateTime [, mask] [, timezone]) → returns String

Member Function Syntax

datetime.dateTimeFormat([mask] [, timezone])

Argument Reference for the dateTimeFormat function

dateTime

Required: Yes
A datetime value. Values:
  • now()

mask

Required: No
The mask used to format the datetime. Values:
  • short
  • medium
  • long
  • full
  • see tokens above

timezone

Required: No
The timezone to use. Can be 3 letter code (UTC) or full America/New_York Values:
  • UTC
  • GMT
  • America/Chicago

Compatibility

ColdFusion:

Version 10+ ColdFusion 10 added this function. Member function is available in CF 11+.

OpenBD:

Some of the mask tokens differ from Adobe ColdFusion

Lucee:

Version 4.5+ The timezone argument does not appear to convert the date from the system timezone to the specified timezone as it does in ACF. Member function is not available.

Railo:

Version 4.0.1+ No documentation exists for this function on Railo, however LSDateTimeFormat is documented. Follows Java date time mask. For details, see the section Date and Time Patterns at the following URL: http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html

Links more information about dateTimeFormat

Examples sample code invoking the dateTimeFormat function


Mask = Short Example

dateTimeFormat("2015-04-11 19:02", "short")

Expected Result: 4/11/15 7:02 PM


Mask = Medium Example

dateTimeFormat("2015-04-11 19:02", "medium")

Expected Result: Apr 11, 2015 7:02:00 PM


Mask = Long Example

dateTimeFormat("2015-04-11 19:02", "long")

Expected Result: April 11, 2015 7:02:00 PM UTC


Mask = Full Example

dateTimeFormat("2015-04-11 19:02", "full")

Expected Result: Saturday, April 11, 2015 7:02:00 PM UTC


Fork me on GitHub