Dernière mise à jour le
11 janv. 2022
|
S’applique également à ColdFusion
Description
Formats date and time values using locale-specific date and time formatting conventions.
Returns
A formatted date and time value.
Category
Syntax
LSDateTimeFormat (date , mask) LSDateTimeFormat (date [, mask, locale]) LSDateTimeFormat (date [, mask, locale, timezone])
See also
LSParseDateTime, LSTimeFormat, DateFormat, SetLocale; Handling data in ColdFusion in the Developing ColdFusion Applications
History
- ColdFusion (2018 release): Changed parameter name timeZone to timezone.
- ColdFusion (2016 release) Update 3: The masks t and tt return the character string A/P or AM/PM respectively. Use t or tt instead of the mask a.
- ColdFusion 10: Added the function.
Parameters
Parameter |
Description |
---|---|
date |
Required. A date/time object, in the range 100 AD-9999 AD. |
mask |
Optional. Mask that has to be used for formatting. See DateTimeFormat. |
timezone |
The time-zone information. You can specify in either of the following formats:
|
locale |
Locale to use instead of the locale of the page when processing the function. |
Example
<cfset todayDateTime = Now()> <body> <h3>DateTimeFormat Example</h3> <p>Today's date and time are <cfoutput>#todayDateTime#</cfoutput>. <p>Using DateTimeFormat, we can display that date and time in different ways: <cfoutput> <ul> <li>#DateTimeFormat(todayDateTime, "yyyy.MM.dd G 'at' HH:nn:ss z")# <li>#DateTimeFormat(todayDateTime, "EEE, MMM d, ''yy")# <li>#DateTimeFormat(todayDateTime, "h:nn a")# <li>#DateTimeFormat(todayDateTime, "hh 'o''clock' a, zzzz")# <li>#DateTimeFormat(todayDateTime, "K:nn a, z")# <li>#DateTimeFormat(todayDateTime, "yyyyy.MMMMM.dd GGG hh:nn aaa")# <li>#DateTimeFormat(todayDateTime, "EEE, d MMM yyyy HH:nn:ss Z")# <li>#DateTimeFormat(todayDateTime, "yyMMddHHnnssZ", "English (UK)", "GMT")# </ul> </cfoutput>
Adobe
Recevez de l’aide plus rapidement et plus facilement
Nouvel utilisateur ?