What exactly does the T and Z mean in timestamp?(时间戳中的 T 和 Z 到底是什么意思?)
问题描述
我有这个时间戳值由 Web 服务返回 "2014-09-12T19:34:29Z"
I have this timestamp value being return by a web service "2014-09-12T19:34:29Z"
我知道它的意思是时区,但它到底是什么意思?
I know that it means timezone, but what exactly does it mean?
我正在尝试模拟这个网络服务,那么有没有办法在 python 中使用 strftime 生成这个时间戳?
And I am trying to mock this web service, so is there a way to generate this timestamp using strftime in python?
很抱歉,这很明显,但 Google 并没有提供多大帮助,strftime() 参考页也没有提供帮助.
Sorry if this is painfully obvious, but Google was not very helpful and neither was the strftime() reference page.
我目前正在使用这个:
x.strftime("%Y-%m-%dT%H:%M:%S%Z")
'2015-03-26T10:58:51'
推荐答案
T 并不代表任何东西.它只是 ISO 8601 组合日期时间格式 所需的分隔符.您可以将其理解为 Time 的缩写.
The T doesn't really stand for anything. It is just the separator that the ISO 8601 combined date-time format requires. You can read it as an abbreviation for Time.
Z 代表 Zero 时区,因为它从 协调世界时 (UTC).
The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC).
这两个字符都只是格式中的静态字母,这就是 datetime.strftime() 方法没有记录它们的原因.您可以使用 Q 或 M 或 Monty Python 并且该方法也会将它们原封不动地返回;该方法仅查找以 % 开头的模式,以用来自 datetime 对象的信息替换这些模式.
Both characters are just static letters in the format, which is why they are not documented by the datetime.strftime() method. You could have used Q or M or Monty Python and the method would have returned them unchanged as well; the method only looks for patterns starting with % to replace those with information from the datetime object.
这篇关于时间戳中的 T 和 Z 到底是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:时间戳中的 T 和 Z 到底是什么意思?
基础教程推荐
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
