NodeJS responded MySQL timezone is different when I fetch directly from MySQL

前端 未结 6 1874
深忆病人
深忆病人 2020-12-03 05:10

When I request MySQL directly, I get back date in UTC (I set UTC in MySQL server), but with NodeJS I get UTC+2 local time zone data, why? How can I set NodeJS to get UTC?

6条回答
  •  鱼传尺愫
    2020-12-03 06:05

    You can also set the dateStrings property to DATETIME.

    dateStrings: Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects. (Default: false)

    Refer: https://github.com/mysqljs/mysql#connection-options

提交回复
热议问题