-
Notifications
You must be signed in to change notification settings - Fork 300
Description
Details
I am experiencing an issue with the timezone data in Node.js. Even though I have updated the tzdata package on my Ubuntu system, Node.js is still showing incorrect time for the Asia/Tehran timezone. I have checked that the system time on Ubuntu is correct, and I have also tested with the toLocaleString method in Node.js to verify that it is using the correct timezone name. However, the time displayed by Node.js is still off by +4.30 hours.
I have found that this issue was discussed in this GitHub issue (#1843) and it seems that Node.js obtains its timezone data from the ICU library, which is periodically updated with its own tzdata. I believe that this issue was fixed in Node.js v16.18.0 (nodejs/node#44283), but I am experiencing the issue in Node.js v14.17.3.
Node.js version
Node.js v14.17.3
Example code
const now = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
timeZone: 'Asia/Tehran',
timeZoneName: 'short'
});
const timezone = formatter.formatToParts(now).find(part => part.type === 'timeZoneName').value;
console.log(timezone); // GMT+4:30
It should be GMT+3:30
Operating system
uname -a
Linux mostafa-pc 6.0.0-x64v2-xanmod1 #0~20221003.git3325905 SMP PREEMPT_DYNAMIC Mon Oct 3 21:25:40 UT x86_64 x86_64 x86_64 GNU/Linux
Scope
Runtime
Module and version
No response