When you go to https://worldtimeapi.org/api/timezone/Europe/Berlin it says raw_offset=3600 , i'm trying to get this value in Node.JS. Need help please, i'm giving my code below but it's giving me wrong output
const moment = require("moment-timezone");
let timezone = "Europe/Warsaw";
let haha = moment().tz(timezone);
let timezone_raw = haha.utcOffset()
CodePudding user response:
Doesn't look wrong they just use a different format.
Worldtime-API seems to use seconds where moment.js seems to use minutes.
According to my test moment.js also returns 60 from utcOffset()
.
You can either take the raw_offset
and divide it by 60 (seconds per minute) to get 60 (minutes).
Or you can take the return from utcOffset()
and multiply it by 60 to get 3600.