node.jstimezonefastifypino

Pino logger timezone is not lined up with system timezone


There is Fastify app with pino logger on AlmaLinux 9.2 using pm2.

$ timedatectl:

Local time: Mon 2025-06-09 22:23:54 +05
  Universal time: Mon 2025-06-09 17:23:54 UTC
  RTC time: Mon 2025-06-09 17:23:53
  Time zone: Asia/Almaty (+05, +0500)
System clock synchronized: yes
  NTP service: active
  RTC in local TZ: no

Fastify app:

 logger: {
    level: 'info',
    transport: { 
      target: 'pino-pretty',
      options: {
        translateTime: 'SYS:yyyy-mm-dd HH:MM:ss Z'
      },
    }
  }

pm2.config:

"env": {
   "TZ": "Asia/Almaty"
}

System timezone = +5, that is right, but log contains wrong timezone = +6:

[2025-06-09 23:14:41 GMT+0600] INFO: request completed

How to line up this dates?


Solution

  • Kazakhstan changed from UTC+6 to UTC+5 in 2024, with the data for Asia/Almaty reflected in tzdata 2024a. Something is simply using the old tzdata and needs updating. Probably your Node.js version.

    Update Node.js to the latest version (or the latest patch for your chosen major version), and the issue should correct itself.