See also
Now, CreateDate, LSDateFormat, LSParseDateTime, LSTimeFormat, TimeFormat, ParseDateTime
History
ColdFusion MX: Added support for the following mask parameter options: short, medium, long, and full.
Parameters
Parameter
|
Description
|
---|
date
|
Date/time object, in the range 100 AD-9999 AD.
|
mask
|
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. Ignored. Reserved. The following masks tell how to format the full date and cannot be combined with other masks:
- short: equivalent to m/d/y
- medium: equivalent to mmm d, yyyy
- long: equivalent to mmmm d, yyyy
- full: equivalent to dddd, mmmm d, yyyy
- z: Time zone in literal format, for example, IST
- Z: Time zone in hours of offset (RFC 822 TimeZone), for example, +0530
- X: Time zone in hours of offset in ISO 8601 format. The following are the three ways of using 'X':
- X: +05
- XX: +0530
- XXX: +5:30
|
Usage
When passing a date/time object as a string, enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object.
You can pass the CreateDate function or Now function as the date parameter of this function; for example: #DateFormat(CreateDate(2001, 3, 3))#
|
Date and time values in database query results can vary in sequence and formatting unless you use functions to format them. To ensure that application users correctly understand displayed dates and times, Adobe recommends that you use this function and the LSDateFormat, TimeFormat, and LSTimeFormat functions to format resultset values.
The DateFormat function is best used for formatting output, not for formatting input. For formatting input, use one of the date/time creation functions (for example, CreateDate) instead.
|
Example