CFLib.org – Common Function Library Project

parseEuroDate(euroDate)

Last updated May 13, 2003

author

Nathan Dintenfass

Version: 1 | Requires: CF6 | 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:

<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:

/**
 * 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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson