nodejs 和 postgres 中的日期转换

Date conversion in nodejs and postgres

我在 postgres 中有类型为 date 的生日列,我从前端收到一个 unixtimestamp,如 716500800。当我将它保存到 postgresql 时,它似乎正在根据我的本地时区进行转换。我不明白我应该做什么,这是一个代码

const date = moment.utc(data.birthday * 1000).format();
console.log(date); // 1992-09-15T00:00:00Z it is right date

db.query(
  'UPDATE app_users SET birthday= where id= RETURNING birthday',
  [
    date,
    id
  ],
  (err, bd) => {
    console.log(bd.rows); // birthday: 1992-09-14T20:00:00.000Z
  }

所以我将服务器和数据库上的时区设置为 UTC。从前端我得到时区和 chande db 字段到 timestamptz(带时区)。现在,我使用 UTC 中的所有日期和来自具有时区的客户端的 show/get。