The problem was that moment-timezone.js version was outdated in the official webpage. Now, it works correctly.
momentJS Timezone fails while converting into unix time
-
18-06-2023 - |
Question
I am trying to convert times from different timezones into unix time. For example:
var spain = moment.tz("18/03/2014 00:00", "DD/MM/YYYY HH:mm", "Europe/Madrid").unix();
var chile = moment.tz("18/03/2014 00:00", "DD/MM/YYYY HH:mm", "America/Santiago").unix();
After these lines, both variables have the same value in my System (currently in Madrid time: 1395097200). AFAIK, the unix time should represent the number of seconds since 1970/01/01 0:00:00 UTC.
Am I doing something wrong?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow