[Javascript] European Date Formatting?

Tim Makins spindrift at oceanfree.net
Mon Aug 9 05:18:49 CDT 2004


lateral thinking - if all you need is the number of days, and your code
works with the USA date format, why not just swap the format from dd/mm/yy
to mm/dd/yy on your two dates when you enter your routine? easy-peasy.

Tim in Ireland.

----- Original Message ----- 
From: "Paul McGuire" <pmcguire at cguk.co.uk>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Monday, August 09, 2004 10:19 AM
Subject: [Javascript] European Date Formatting?


> Hi ALL,
>
> I need to work out the number of days between two dates. However if I pass
> 01/02/02 into the below script it insists on working out a difference
using
> the date 2nd Jan 02 but as far as I am concerned (and millions of others)
> the above date is infact 1st Feb 02. I have tried
laterdate.toLocaleString()
> but this does not seem to have any effect whatsoever. How am I meant to
> force JavaScript to accept European formatted dates?
>
> My Code:
>
> var difference = laterdate.getTime() - earlierdate.getTime();
>
>     var daysDifference = Math.floor(difference/1000/60/60/24);
>     difference -= daysDifference*1000*60*60*24
>     var hoursDifference = Math.floor(difference/1000/60/60);
>     difference -= hoursDifference*1000*60*60
>     var minutesDifference = Math.floor(difference/1000/60);
>     difference -= minutesDifference*1000*60
>     var secondsDifference = Math.floor(difference/1000);
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list