I have two date/time stamps:
d1 = 2011-03-02T15:30:18-08:00
d2 = 2011-03-02T15:36:05-08:00
I want to be above to compare the two:
Seems to work fine for me, although you have to format correctly (i.e. semicolons, quotes):
var d1 = "2011-03-02T15:30:18-08:00";
var d2 = "2011-03-02T15:36:05-08:00";
if(new Date(d1) < new Date(d2)) {alert('newer')};
And yes, it takes time into account. If you do this:
alert(new Date(d1) - new Date(d2));
You get 347000, which is 347 seconds, or 5 minutes, 47 seconds. This is the correct difference between the two.