LSDateFormat

Description

Formats the date portion of a date/time value using the locale convention. Like DateFormat, LSDateFormat returns a formatted date/time value. If no mask is specified, LSDateFormat returns a date value using the locale-specific format.

Category

International functions

Syntax


LSDateFormat(date [, mask ]) 

Parameters

Parameter
Description
date
Date/time object in the range 100 AD-9999 AD.
mask
Characters that show how ColdFusion displays the date.
ColdFusion uses two different default masks, depending on the locale. For a locale where the year is at the end of the date string, the default mask is: dd-mmm-yy. For a locale that has the year first in dates (such as Sweden), the default mask is yyyy-mmm-dd.
Options are:
  • d    Day of the month; digits; no leading zero for single-digit days
  • dd    Day of the month; digits; leading zero for single-digit days
  • ddd    Day of the week; three-letter abbreviation
  • dddd    Day of the week; full name
  • m    Month; digits; no leading zero for single-digit months
  • mm    Month; digits; leading zero for single-digit months
  • mmm    Month; three-letter abbreviation
  • mmmm    Month; full name
  • y    Year; last two digits; no leading zero for years less than 10
  • yy    Year; last two digits; leading zero for years less than 10
  • yyyy    Year; four digits
  • gg    Period/era string. Currently ignored. Reserved for future use

Usage

When passing date/time value as a string, enclose it in quotes. Otherwise, it is interpreted as a number representation of a date/time object.

Example

<!--- This shows LSDateFormat --->

<html>

<head>

<title>LSDateFormat Example</title>

</head>



<body>

<H3>LSDateFormat Example</H3>



<P>LSDateFormat formats the date portion 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><BR>

    #LSDateFormat(Now(), "mmm-dd-yyyy")#<BR>

    #LSDateFormat(Now(), "mmmm d, yyyy")#<BR>

    #LSDateFormat(Now(), "mm/dd/yyyy")#<BR>

    #LSDateFormat(Now(), "d-mmm-yyyy")#<BR>

    #LSDateFormat(Now(), "ddd, mmmm dd, yyyy")#<BR>

    #LSDateFormat(Now(), "d/m/yy")#<BR>

    #LSDateFormat(Now())#<BR>    

    <Hr noshade>

  </cfoutput>



</CFLOOP>



</body>

</html> 





Banner.Novgorod.Ru