This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the javascript category.
Last Updated: 2024-11-21
Solution 1: They will have different TimezoneOffsets
startDate.getTimezoneOffset()
-60
endDate.getTimezoneOffset()
-120
Solution 2: When logged, one will say Standard Time
and the other will
say Summer Time
.
console.log(startDate)
=> Wed Nov 05 2008 00:00:00 GMT+0100 (Central European Standard Time)
console.log(endDate)
// notice how the Summer/Standard bit is only at the end of the input...
// be sure to read the full thing!
=> Wed Jul 01 2009 00:00:00 GMT+0200 (Central European Summer Time)
Why was the TimezoneOffset negative?
I am writing from Germany, GMT+1 (not summer time). That means 2pm here corresponds to 1pm in the UK. So, from my perspective, the amount I would need to modify the current time by - i.e. the offset - would be -60 minutes in standard time (and -120 minutes in summer time). The baseline is not whether there is also daylight savings time in the UK - but rather a platonic unmoving time center.