LSParseDateTime

Description

Formats a date/time string in a locale-specific format. Does not parse POP date/time objects.

Return value

A formatted date/time value.

Category

Date and time functions, Display and formatting functions, International functions, String functions

Syntax

LSParseDateTime(date/time-string) 

See also

LSDateFormat, ParseDateTime, SetLocale

History

New in ColdFusion MX: This function might return different formatting than in earlier releases. This function uses Java standard locale formatting rules on all platforms.

New in ColdFusion MX: ColdFusion processes the date/time string parameter value differently than in earlier releases:

Macromedia recommends that, when developing an application, you evaluate the entered time string for a time zone setting; ensure that your application adjusts the value, if necessary. (To do this, you can use a cfcatch tag.)

Parameters

Parameter Description
date/time-string
A string a variable that contains one, in a format that is readable in the current locale. Default: English (US) locale.

Usage

This function uses Java standard locale formatting rules on all platforms.

ColdFusion uses the following date/time string length formats:

You can pass a date/time value to this function that is in the English (US) locale, in any of the following date or date/time formats:
Mask Format Example
Jan dd, yyyy
Date, Default
Jan 30, 2002
m/dd/yy
Date, Short
1/30/02
m dd, yyyy
Date, Medium
Jan 30, 2002
mmmm dd, yyyy
Date, Long
January 30, 2002
Wednesday, mmmm dd, yyyy
Date, Full
Wednesday, January 30, 2002
Jan dd, yyyy 7:mm:ss AM
Date/time, Default
Jan 30, 2002 7:02:12 AM
m/dd/yy 7:mm AM
Date/time, Short
1/30/02 7:02 AM
Jan dd, yyyy 7:mm:ss AM
Date/time, Medium
Jan 30, 2002 7:02:12 AM
mmmm dd, yyyy 7:mm:ss AM PST
Date/time, Long
January 30, 2002 7:02:12 AM PST
Wednesday, mmmm dd, yyyy 7:mm:ss AM PST
Date/time, Full
Wednesday, January 30, 2002 7:02:12 AM PST
{ts 'yyyy-07-06 hh:mm:ss'}
Date/time, None
{ts '2003-07-06 00:00:00'}

A date/time object is in the range 100 AD-9999 AD. See "How ColdFusion processes two-digit year values".

To set the default display format of date, time, number, and currency values, use the SetLocale function.

Note:   This function does not accept POP dates.

Example

<h3>LSParseDateTime Example - returns a locale-specific date/time object</h3>
<!--- loop through a list of locales and 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>
    <p>Locale-specific formats:
    <br>#LSDateFormat(Now(), "mmm-dd-yyyy")# #LSTimeFormat(Now())#<br>
    #LSDateFormat(Now(), "mmmm d, yyyy")# #LSTimeFormat(Now())#<br>
    #LSDateFormat(Now(), "mm/dd/yyyy")# #LSTimeFormat(Now())#<br>
    #LSDateFormat(Now(), "d-mmm-yyyy")# #LSTimeFormat(Now())#<br>
    #LSDateFormat(Now(), "ddd, mmmm dd, yyyy")# #LSTimeFormat(Now())#<br>
    #LSDateFormat(Now(), "d/m/yy")# #LSTimeFormat(Now())#<br>
    #LSDateFormat(Now())# #LSTimeFormat(Now())#<br>
  <p>Standard Date/Time:
  #LSParseDateTime("#LSDateFormat(Now())# #LSTimeFormat(Now())#")#<br>
  </cfoutput>
</cfloop>

Comments