【发布时间】:2021-12-12 15:56:37
【问题描述】:
>>> mtime
1634725796.7212281
>>> from datetime import datetime
>>> datetime.fromtimestamp(mtime)
datetime.datetime(2021, 10, 20, 15, 59, 56, 721228)
>>>
我希望准确返回格式为 Date: Wed, 20 Oct 2021 15:59:56 GMT 的日期时间字符串,这是上次修改页面时服务器发送的格式。
https://serverfault.com/questions/168345/sending-content-message-body-along-with-304-not-modified-header
【问题讨论】:
-
别忘了设置GMT;
datetime.fromtimestamp(mtime, tz=timezone.utc)
标签: python-3.x datetime