I'm working on an Nodejs system support multi timezone users. Currently, I'm using moment.tz.names() to get list of available timezone. But I found out that some timezone in list is deprecated by this link. I also found this database from IANA. So is there anyway to keep my timezone data up to date? I'm trying to find a way to work with IANA database. Thank you if there are any other approaches.
Asked
Active
Viewed 2,551 times
3
-
1Moment.js is no longer maintained, so the problem is likely to get worse. – Robby Cornelissen Mar 05 '21 at 10:03
-
I knew it, but my system is using moment to deal with timezone problems. We are moving to date-fns, I don't know if date-fns have a timezone list themselves? – Nguyen Hoang Vu Mar 05 '21 at 10:04
1 Answers
3
I'd take a look at the tzdb package. It includes all IANA zones and is automatically updated on changes. You can get a list of timezones easily:
const { getTimeZones } = require("@vvo/tzdb");
const timeZones = getTimeZones();
console.log("Timezone (Berlin):", timeZones.find(tz => tz.name === "Europe/Berlin"));
console.log("Timezone (LA):", timeZones.find(tz => tz.name === "America/Los_Angeles"));

Terry Lennox
- 29,471
- 5
- 28
- 40
-
1I found this package days ago but I don't know whether it is still valid. I will give it a try today. – Nguyen Hoang Vu Mar 08 '21 at 04:04
-
1Thank you, package include a const called timeZonesNames which is my target. – Nguyen Hoang Vu Mar 08 '21 at 04:31