Your Rating: Results: PatheticBadOKGoodOutstanding! 2 rates

Description

Formats date and time values using date and time formatting conventions.

Returns

A formatted date and time value.

History

ColdFusion 10: Added this function.

Syntax

dateTimeFormat (date_)dateTimeFormat (_date [, mask_])dateTimeFormat (_date [_, mask, _timeZone])

Properties

Parameter

Description

date

Required. A date/time object, in the range 100 AD-9999 AD.

mask

Optional. Characters that show how ColdFusion displays a date:

  •     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.
  •     ddd: Day of the week as a three-letter abbreviation.
  •     dddd: 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.
  •     gg: 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

The following masks tell how to format the full date and time and cannot be combined with other masks:

  • short: equivalent to m/d/y h:mm tt
  • medium: equivalent to mmm d, yyyy h:mm:ss tt
  • long: medium followed by three-letter time zone; as in, mmmm d, yyyy h:mm:ss tt EST
  • full: equivalent to dddd, mmmm d, yyyy h:mm:ss tt EST
The function also follows Java date time mask. For details, see the section Date and Time Patterns on this page.

timeZone

The time-zone information. You can specify in either of the following formats:

  • Abbreviation such as GMT or PST
  • Full name such as Europe/Dublin
    By default, this is the time-zone followed by the system.

Example

Labels
  • None
  1. Feb 24, 2014

    The values given for the mask attribute do not match the values used in the examples and do not match the linked Java date time mask.

    For example, when trying to output the name of day of the week (Monday, Tuesday) the mask suggests using 'dddd' whereas the linked documentation says to use 'EEEE'.

    Using dddd results in 0025 (on 25th Feb) whereas EEEE results in Tuesday (which is correct.)

    TLDR use the linked Java date time masks in preference to the details on this page.

     

  2. Apr 01, 2014

    In the mask parameter description for bullet points short, medium, long and full, the mask has "mm" for seconds which should read "nn".

    Example:

    short: equivalent to m/d/y h:mm tt

    Should be:

    hort: equivalent to m/d/y h:nn tt


Searching ColdFusion English Documentation