node js get time in timezone
// Javascript timestamps are specified in milliseconds let ts = 1581338765000; let nz_date_string = new Date(ts).toLocaleString("en-US", { timeZone: "Pacific/Chatham" }); // rest of the code
Here is what the above code is Doing:
1. We’re creating a timestamp (ts) that represents the time of the earthquake.
2. We’re creating a new Date object using the timestamp.
3. We’re using the toLocaleString() method to convert the date to a string.
4. We’re specifying the time zone as “Pacific/Chatham” so that the date is converted to the Chatham Islands time zone.