parseEuroDate(euroDate)
Last updated May 13, 2003
Version: 1 | Requires: ColdFusion MX | Library: DateLib
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:
<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:
<cfscript>
/**
* Makes a "European" 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>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
11 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
29 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)