I want to verify if daylight saving time is active by using the isDST() function. When I check it with the current date and time using var isdst = moment().isDST(), it works correctly for my timezone and returns true. However, I need to first set the timezone offset before checking if daylight saving time is active in that specific timezone. The code I have written below shows what I have tried:
var isdst = moment('2014-03-28').zone('+01:00');
console.log('daylight savings for +0100 is ' + isdst); //this returns true instead of false
For example, considering the DST time for timezone +0100 (European Union countries), it should only be in effect starting March 30, 2014. Strangely, the code above returns true on March 28 when it shouldn't until 2 days later. You can confirm this information by checking the DST timings for different countries here.
Upon further testing, I observed that the code seems to be somehow referencing my own timezone (US Eastern Standard) even though I'm setting a different zone. For instance, since Eastern Standard daylight saving begins on March 9, 2014, the code will return false a few days before that date (such as on March 8) and true afterwards (like on March 11). This indicates that it's not recognizing the zone("+0100") I specified and is using my local timezone instead. Why is this happening? How can I accurately set the timezone for a momentjs date? I checked the documentation (here) and followed the suggested method, but it doesn't seem to work as expected.