-1

I have this code:

var d1 = new Date(Date.UTC(2011, 0, 1));
var d2 = new Date(Date.UTC(2011, 0, 1));

if (d1 == d2) { alert('Equals1'); }
if (d1 === d2) { alert('Equals2'); }
if (d1 < d2)  { alert('d1 < d2'); }
if (d1 > d2)  { alert('d1 > d2'); }

Could someone tell me WHY I can't comparing these two dates? You can run the script here: http://jsfiddle.net/vSL47/

These two dates should be equals, no?

Thanks

2

1 Answer 1

0

For a more simple answer:

if (d1.toString() == d2.toString()) { alert('Equals1'); }

Works

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.