I use the moment-timezone v.0.5.3-2016c
library to calculate the UTC offset for a timezone:
var z = moment().tz("America/Los_Angeles");
z.utcOffset(); // -420 mins or -7 hours
// check if DST is shifted
z.isDSTShifted(); // false
But here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones the UTC offset for the America/Los_Angeles
is -8 hours.
Moment uses the tzdb v.2016c and the wikipedia article too.
Well, why there are two different results here? And which result is right?
P.S.: there is the same difference for America/Kentucky/Monticello
and Europe/Tiraspol
, as well.
Calling the moment creation function, moment()
without any arguments returns the current moment in time. Since time zone offsets vary depending on what date and time they are attached to, your results will vary depending on when you call this function.
If you want to know whether or not the time is daylight saving time or not, use isDST
. The isDSTShifted
function is for dealing with invalid local times, not checking DST. It probably could have been named better.
The USA is currently in DST (Daylight Savings Time). Therefore, I'd use the UTC DST Offset
column, which shows -07:00
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With