Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ionic JavaScript Date object is not respecting Daylight Savings Time (DST)

ANSWERED

The JS Date object on the Ionic does not appear to be correctly respecting daylight savings time.  I'm trying to work with dates in the future, in the Eastern US timezone.  

 

The correct unix timestamp for midday (12:00) on July 1st 2018 should be 1530460800000.
In Chrome, this will create the following date via new Date(1530460800000).

Sun Jul 01 2018 12:00:00 GMT-0400 (EDT)

And getTimezoneOffset() returns 240 for that date.  Which is correct, a 4 hour difference to UTC.

 

However, the same code run on the Ionic returns: 

Sun Jul 01 2018 11:00:00 GMT-05:00

And getTimezoneOffset() returns 300 for that date.  Which is incorrect, is is still a 5 hour difference.

 

This is pretty problematic when trying to work with dates in the past and future.  Am I missing something here, or is this a bug?

 

You can try it for yourself with the code below:

let unix_ts_jul = 1530460800000;
let date_jul = new Date(unix_ts_jul);
console.log("Date for 1st July from TS");
console.log(date_jul);
console.log("TZ offset for 1st July from TS");
console.log(date_jul.getTimezoneOffset());

 

Best Answer
1 BEST ANSWER

Accepted Solutions

Thanks for reporting this, I've raised it with the firmware team, and will update you when I find out more.

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

Thanks for reporting this, I've raised it with the firmware team, and will update you when I find out more.

Best Answer
0 Votes