Search code examples
node.jstimezonemoment-timezone

Valid IANA timezone list


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.


Solution

  • 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"));