Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Calling new Date(String s) produces result in different timezone

I am trying to display a date in javascript. I receive the date from backend like this: 2020-09-22T17:10:25Z (from and Instant object in Java).

When I try to call new Date("2020-09-22T17:10:25Z") I get: Tue Sep 22 2020 20:10:25 GMT+0300 (Eastern European Summer Time). The issue with this is that I am not in a GMT+0300 timezone but rather GMT+0200.

When I try to call new Date() on the other hand I get Thu Dec 08 2022 20:34:11 GMT+0200 (Eastern European Standard Time) which is my correct timezone.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My question is, why in the first case I get the GMT+0300 and in the second case I get GMT+0200? The Z in the string I am trying to parse stands for Zulu or zero hour offset, so why does the 2 different approaches use different timezones?

>Solution :

It looks like you are in GMT+2 in winter, but in summer (in September) you are in summer time which is GMT+3

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading