Hi,
I m trying to compare 2 dates in java script.
I have the datestring(s), say Dec 22, 2006 and Dec 21, 2006
I am using
var a = new Date('Dec 22, 2006');
var b = new DatE('Dec 21, 2006');
And am able to compare a%26lt;b, b%26lt;a, and a==b successfully
But when the date String is in spanish, french etc. where we have date strings as
dic 22, 2006, dic 21, 2006 - the above code isn't able to understand it.
Any suggestions on how this should be done ?? .
Date Comparision in Javascript - String is Language Specific?
The best thing to do is to more explicitly construct your dates, or to use UTC time instead of locale.
For example:
var a = new Date();
a.setMonth = 11;
a.setDate = 22;
a.setYear = 2006;
var b = new Date();
b.setMonth = 11;
b.setDate = 21;
b.setYear = 2006;
var a = new Date('Dec 22, 2006').toUTCString();
var b = new Date('Dec 21, 2006').toUTCString();
http://www.w3schools.com/jsref/jsref_obj...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment