Reputation: 11
Please see the attached screenshots. Why is this happening and what is the best solution?
The code for both is:
var d = new Date("2018-03-30T00:00:00");
document.getElementById("demo").innerHTML = d;
Fri Mar 30 2018 00:00:00 GMT-0700 (PDT)
Thu Mar 29 2018 17:00:00 GMT-0700 (PDT)
Upvotes: 0
Views: 516
Reputation: 251062
One of your browsers is assuming the input is in a different timezone to the other.
Try creating the date with timezone information:
var d = new Date("2018-03-30T00:00:00.000Z");
or,
var d = new Date("Fri, 30 Mar 2018 00:00:00 GMT");
Upvotes: 1