I have to admit, I've never quite understood Javascript date objects, but now I'm really confused with how they are constructed. Consider the following:
var x = new Date('2017-01-01');
var y = new Date('2017-01-01 00:00:00');
// x
// Sat Dec 31 2016 19:00:00 GMT-0500 (Eastern Standard Time)
// y
// Sun Jan 01 2017 00:00:00 GMT-0500 (Eastern Standard Time)
console.log(x);
console.log(y);
How or why are x
and y
producing different values? From what I'm used to (C#, SQL, common sense, etc.), 2017-01-01
is the same as 2017-01-01 00:00:00
. Can someone enlighten me on why the resulting Date
values are not the same?