JavaScript, Date, toUTCString()
Posted by sharpstyle on April 12, 2007
Consider the following code
var a = new Date();
var b = new Date(a.toUTCString());
alert(b – a);
My expectation that it will return 0, but it was consistently returning negative values as if b was an earlier date than a.
How is that possible? toUTCString() drops milliseconds, which essentially makes b an earlier date than a.
~Mike
Advertisement
No Comment said
Because a is not UTC and will have a different value than b which is UTC.