Why are the calculated dates different in Internet Explorer and Chrome?

So, I use this to try to get the day to today. This works fine in Chrome, but IE thinks about it the day before. My current system date is 05/05/2014 10:14 (PST).

var todaysDate = new Date();
var maxDate = new Date(Date.UTC(todaysDate.getFullYear(),todaysDate.getMonth(),todaysDate.getDate()-1));

It is worth noting that both IE and Chrome return a value of 9 for the next.

console.log(todaysDate.getDate());

So, if today = 05/05/2014 (PST)

Chrome gets 05/05/2014

IE gets 05/05/2014

What's happening? Why does IE interpret this differently in Chrome?

+4
source share
1 answer

This is a time zone problem - timeouts behind GMT will be discarded during the day by your code.

"" 12. , .

, UTC + 14 - . todaysDate.getUTC* //.

+3

Source: https://habr.com/ru/post/1539935/


All Articles