【问题标题】:Typeorm converting date to +3 hours?Typeorm将日期转换为+3小时?
【发布时间】:2022-01-17 23:50:03
【问题描述】:

当我访问我看到的数据库时,我尝试像在我的 postgresSQL 中一样获取寄存器的真实小时数

DB Register with Date Today, 11:30

当我提出请求时

const tomorrow = moment().add(1, 'days');
const today = moment().startOf('day');
return this.ormRepository.find({
  where: {
    startHour: MoreThanOrEqual(today),
    endHour: LessThanOrEqual(tomorrow),
  },
  order: { startHour: 'ASC' },

  join: {
    alias: 'reserves',
    leftJoinAndSelect: {
      table: 'reserves.table',
    },
  },
});

}

使用 typeorm 查看 postgres 寄存器我看到今天不同的时间,14:30。

Today 14:30 Sample

我不知道发生了什么,在任何文档中都找不到它,在生产中一切正常,问题出在我的开发中,我找不到任何解决方案。

我在 docker 容器中测试了我的代码,日期即将到来(今天,11:30)

更新:我暂时解决了将计算机时间更改为 UTC 的问题

【问题讨论】:

    标签: node.js postgresql date typeorm


    【解决方案1】:

    你在 postgres 中设置了什么类型的字段?时间戳?

    在 postgres 中,如果你执行 select Date() 你会收到 UTC

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-01
    • 2018-10-15
    • 2019-11-26
    • 2020-03-25
    • 2023-03-24
    • 1970-01-01
    相关资源
    最近更新 更多