T和Z在时间戳中是什么意思? [英] What exactly does the T and Z mean in timestamp?

查看:7399
本文介绍了T和Z在时间戳中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个时间戳值由webservice返回2014-09-12T19:34:29Z



我知道这意味着时区,但究竟是什么意思?



我正在尝试模拟这个webservice,所以有一种方法可以在python中使用strftime生成这个时间戳?



对不起,如果这是很明显的,但谷歌不是很有帮助,也不是strftime()参考页。



我目前使用的是:

  x.strftime( %Y-%m-%dT%H:%M:%S%Z)
'2015-03-26T10:58:51'


解决方案

T 并不代表任何东西。 ISO 8601组合日期时间格式要求的只是分隔符。您可以将其阅读为时间的缩写。



Z 代表 时区,由于协调世界时(UTC)偏移0 。



这两个字符都是格式的静态字母,这就是为什么它们不被 datetime.strftime()方法。您可以使用 Q M Monty Python 和该方法也会使它们保持不变;该方法仅查找以开头的模式替换来自 datetime 对象的信息。


I have this timestamp value being return by a webservice "2014-09-12T19:34:29Z"

I know that it means timezone, but what exactly does it mean?

And I am trying to mock this webservice, so is there a way to generate this timestamp using strftime in python?

Sorry if this is painfully obvious, but google was not very helpful and neither was the strftime() reference page.

I am currently using this :

x.strftime("%Y-%m-%dT%H:%M:%S%Z")
'2015-03-26T10:58:51'

解决方案

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.

The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC).

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在时间戳中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆