search

Home  >  Q&A  >  body text

python - Flask 项目中,怎样设置时区?

django 中,设置好时区 Time Zone,就不用再去操心时间的转换问题了。
但是在 Flask 中,就没有这种配置了。
So,怎样解决?

黄舟黄舟2783 days ago1138

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-17 13:45:40

    Does flask have it? Isn't it set in Linux?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:45:40

    My general approach is that when developing APIs, the time zone is not set in the database or view, or in other words, it is set to the 无时区 state by default. That is a utc time.

    The timing is then handled by the API caller. You can pass in the time zone parameter, or directly get the utc time and process it. Compared with the situation xxx hours ago, UTC is OK.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:45:40

    The background time is unified using UTC time, and Monent.js is used when displaying on the client

    reply
    0
  • Cancelreply