gotounix
V2EX  ›  问与答

Python Web 开发中的 datetime 时区问题

  •  
  •   gotounix · Jan 19, 2017 · 1191 views
    This topic created in 3419 days ago, the information mentioned may be changed or developed.
    情况:
    使用 SQLAlchemy ,数据库中存的都是 UTC 时间。

    问题:
    比如:统计 2016 年中各个月的数据量,统计的是 2015-12-31 16:00:00 至 2016-12-31 16:00:00 数据,在使用 extract 出 year 和 month 进行 group by 的时候,就会出现 2015 年 12 月~2016 年 12 月,其实应该是 2016 年 1 月~2016 年 12 月。
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2469 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 15:59 · PVG 23:59 · LAX 08:59 · JFK 11:59
    ♥ Do have faith in what you're doing.