M
M
Maxim Shimko2019-02-13 11:33:35
JavaScript
Maxim Shimko, 2019-02-13 11:33:35

Why does new Date() return the wrong time in JavaScript?

You need to get the user's timezone in the browser. new Date().getTimezoneOffset() gives me -120 when it should give -180 because I have UTC +3. Also, new Date() itself returns the wrong time, instead of 11 hours it returns 10 and the time zone +2, respectively. How can I get the user's actual time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
ZardoZAntony, 2021-02-03
@ZardoZAntony

The same problem was in Google Chrome, I broke my whole head. It turned out that the browser developers screwed up, because. everything is fine in other browsers. Fixed it in the next update.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question