Once I had this "simple" task and I used (new Date()).getTimezoneOffset()
- the approach that is widely suggested here. But it turned out that the solution wasn't quite right.For some undocumented reasons in my case new Date()
was returning GMT+0200 when new Date(0)
was returning GMT+0300 which was right. Since then I always use
(new Date(0)).getTimezoneOffset()
to get a correct timeshift.