lsDateFormat

Formats the date part of a date/time value in a locale-specific format.
[mask - quicky]
d,dd,ddd,dddd: Day of month / week
m,mm,mmm,mmmm: Month
y,yy,yyyy: Year
gg: Period/era string
short / medium / long / full

lsDateFormat(date [, mask, locale]) → returns string

Member Function Syntax

date.lsDateFormat([mask, locale])

Argument Reference

date date
Required

The datetime object

mask string
Default: medium

A keyword or custom combination of components
Values:
  • short
  • medium
  • long
  • full

locale string

CF 8+ Locale to use instead of the locale of the page when processing the function

Compatibility

ColdFusion:

Member function is available in CF11+.

Lucee:

Member function is available in Lucee4.5+.

Examples
Sample code invoking the lsDateFormat function

lsDateFormat formats the date part of a date/time value using the locale convention.

<!--- loop through a list of locales; show date values for now()---> 
 <cfloop list = "#Server.Coldfusion.SupportedLocales#" 
 index = "locale" delimiters = ","> 
 <cfset oldlocale = setLocale(locale)> 
  <cfoutput><p><B><I>#locale#</I></B> 
 #lsDateFormat(now(), "mmm-dd-yyyy")# 
 #lsDateFormat(now(), "mmmm d, yyyy")# 
 #lsDateFormat(now(), "mm/dd/yyyy")# 
 #lsDateFormat(now(), "d-mmm-yyyy")# 
 #lsDateFormat(now(), "ddd, mmmm dd, yyyy")# 
 #lsDateFormat(now(), "d/m/yy")# 
 #lsDateFormat(now())# 
 <hr noshade> 
 </cfoutput> 
 </cfloop> 

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub