2

I am currently in UTC +2 timezone (tripoli). While assigning a date value in ISO string, date values get adjusted with DateLightSaving settings I suspect and the date value itself gets changes. Please check the below link to reproduce the issue.

Link: https://codepen.io/anon/pen/bjbodJ

$(function() {$( "#datepicker" ).datepicker(); $( "#datepicker" ).datepicker("setDate", new Date("1937-02-25T22:00:00.000Z"));});

In the edge browser the value is retunred correctly (Firefox, IE also returns correct value). But value changes only with Google Chrome that too only with current latest version but works fine with older version (65).

Edge working screenshot:

Edge working screenshot:

Chrome issue screenshot:

Chrome issue screenshot:

In the above two screenshots, you can find that the date value has been changed in the Chrome browser by 1 day. whereas it displays same value in Edge browser (also fine with mozilla and IE).

Can anyone suggest on this.

Prem Kumar
  • 161
  • 1
  • 1
  • 7

1 Answers1

0

From 1920 to 1959 Tripoli was at +1:00.

If you want midnight local time on a particular date, you can ask for it, instead of trying to guess what the UTC offset was at that point in time:

> new Date([1937,2,26]).toISOString()
'1937-02-25T23:00:00.000Z'
> new Date([1919,2,26]).toISOString()
'1919-02-25T23:07:16.000Z'
Josh Lee
  • 171,072
  • 38
  • 269
  • 275