• 请不要在回答技术问题时复制粘贴 AI 生成的内容
inSpring
V2EX  ›  程序员

有人在用 Prisma ORM 吗? 有遇到 时区 问题吗?

  •  
  •   inSpring · Apr 26, 2024 · 3225 views
    This topic created in 927 days ago, the information mentioned may be changed or developed.

    Prisma 默认把时间转成 UTC 时区存到数据库,比如 DateTime 字段。

    然后用 Navicat 、DataGrip 等数据库 GUI 查看的时候,看到的就是 UTC 时间,很蛋疼。

    这个时候如果直接在 Navicat 修改某个 DateTime 字段的时间,就很混乱。因为 Navicat 不会和 Prisma 一样,把设置的时间转成 UTC 时区时间存进去。

    在用 Prisma ORM 的朋友们,你们是怎么处理的?

    3 replies  •  2024-04-27 10:56:22 +08:00
    DesnLee
    DesnLee
    Apr 26, 2024
    1
    我用 Postgres
    ppwqdxtc
    ppwqdxtc
    Apr 27, 2024
    2
    改下数据库的时区
    anytinzovo
    anytinzovo
    Apr 27, 2024
    3
    可行的方法应该是写一份 migration 把时间列的格式从默认的 DateTime 格式迁移至带时区的时间戳,但是这个成本估计有点过于的高了...所以最好的方法是处理自己的脑子( bushi
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2036 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 15:00 · PVG 23:00 · LAX 07:00 · JFK 10:00
    ♥ Do have faith in what you're doing.