CFLib.org – Common Function Library Project

parseEuroDate(euroDate)

Last updated May 13, 2003

Version: 1 | Requires: ColdFusion MX | Library: DateLib

 
Rated 0 time(s). Average Rating: 0

Description:
If you are a U.S. developer who has end users in other parts of the world, you may have run into the fact that they write dates with the day before the month, whereas Americans write the month before the day. This function takes a "European-style" date and makes it a "U.S.-style" dateTime string.

Return Values:
Returns a date string.

Example:

view plain print about
<cfset theDate = "05/02/2003">
<cfoutput>
original date string ("dd/mm/yyyy"): #theDate#
<br /><br />
what CF thinks that is on an American machine: #parseDateTime(theDate)#
<br /><br />
what it should be, after using parseEuroDate: #parseEuroDate(theDate)#
</cfoutput>

Parameters:

Name Description Required
euroDate Date string. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Makes a &quot;European&quot; date (day before month) into a U.S. style date.
 * 
 * @param euroDate      Date string. (Required)
 * @return Returns a date string. 
 * @author Nathan Dintenfass (nathan@changemedia.com) 
 * @version 1, May 13, 2003 
 */

function parseEuroDate(euroDate){
    //grab the old locale, so we can switch it back
    var oldLocale = getLocale();
    //a var to hold our dateTime
    var dateTime = "";
    //set the locale to British -- they use the Euro format!
    setLocale("English (UK)");
    //parse it using the localization function for parsing date time
    dateTime = LSParseDateTime(arguments.euroDate);
    //now set the Locale back, so we don't mess up the server
    setLocale(oldLocale);
    //return our dateTime that was parsed
    return dateTime;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
29 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson