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

LSParseDateTimeLSTimeFormatDateFormatSetLocaleHandling data in ColdFusion in the Developing ColdFusion Applications

History

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:

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

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>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy