Dates Equal

by Kyle Mitofsky

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>














<div style='position:fixed;top:0;left:0; background:lightgray;width:100%;'>
    <b>About this SO question</b>:
    <a href='http://stackoverflow.com/a/4428357/1366033'>
        Checking if two Dates have the same date info
    </a><br/>
    <b>Further Reading</b>:
    <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date'>
        MDN - Date Object
    </a><br/>
</div>

JavaScript

var a,b,equal

a = new Date(1995,11,17);
b = new Date(1995,11,17);
equal = a.getTime() === b.getTime(); 
console.log(equal) // prints true

a = new Date(1995,11,17,12);
b = new Date(1995,11,17,11);
equal = a.getTime() === b.getTime(); 
console.log(equal) // prints false