这种格式是什么意思 T00:00:00.000Z? [英] What does this format means T00:00:00.000Z?

查看:78
本文介绍了这种格式是什么意思 T00:00:00.000Z?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以在javascript中解释这种类型的格式

Can someone, please, explain this type of format in javascript

 T00:00:00.000Z

以及如何解析它?

推荐答案

它是 ISO-8601<的一部分/a> 日期表示.这是不完整的,因为此模式中的完整日期表示还应包含日期:

It's a part of ISO-8601 date representation. It's incomplete because a complete date representation in this pattern should also contains the date:

2015-03-04T00:00:00.000Z //Complete ISO-8601 date

如果您尝试按原样解析此日期,您将收到 Invalid Date 错误:

If you try to parse this date as it is you will receive an Invalid Date error:

new Date('T00:00:00.000Z'); // Invalid Date

所以,我想解析这种格式的时间戳的方法是连接任何日期

So, I guess the way to parse a timestamp in this format is to concat with any date

new Date('2015-03-04T00:00:00.000Z'); // Valid Date

然后你可以只提取你想要的部分(时间戳部分)

Then you can extract only the part you want (timestamp part)

var d = new Date('2015-03-04T00:00:00.000Z');
console.log(d.getUTCHours()); // Hours
console.log(d.getUTCMinutes());
console.log(d.getUTCSeconds());

这篇关于这种格式是什么意思 T00:00:00.000Z?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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