ISO 8601 和 RFC 3339 日期格式有什么区别? [英] What's the difference between ISO 8601 and RFC 3339 Date Formats?

查看:32
本文介绍了ISO 8601 和 RFC 3339 日期格式有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ISO 8601RFC 3339 似乎是两种常见的网络格式.我应该使用一个吗?一个只是一个扩展?我真的需要那么在意吗?

ISO 8601 and RFC 3339 seem to be two formats that are common the web. Should I use one over the other? Is one just an extension? Do I really need to care that bad?

推荐答案

它只是一个扩展吗?

Is one just an extension?

差不多,是的 - RFC 3339 被列为 ISO 8601 的配置文件.最值得注意的是 RFC 3339 指定了日期和时间的完整表示(只有小数秒是可选的).RFC 也有一些细微的差别.例如,不允许仅使用两位数的截断年份表示法——RFC 3339 要求使用 4 位数字年份,而 RFC 仅允许将句点字符用作小数秒的小数点.RFC 还允许T"用空格(或其他字符)代替,而标准只允许省略它(并且仅当使用该表示的各方达成一致时).

Pretty much, yes - RFC 3339 is listed as a profile of ISO 8601. Most notably RFC 3339 specifies a complete representation of date and time (only fractional seconds are optional). The RFC also has some small, subtle differences. For example truncated representations of years with only two digits are not allowed -- RFC 3339 requires 4-digit years, and the RFC only allows a period character to be used as the decimal point for fractional seconds. The RFC also allows the "T" to be replaced by a space (or other character), while the standard only allows it to be omitted (and only when there is agreement between all parties using the representation).

我不会太担心两者之间的差异,但是如果您的用例遇到它们的可能性很小,那么值得一看:

I wouldn't worry too much about the differences between the two, but on the off-chance your use case runs in to them, it'd be worth your while taking a glance at:

这篇关于ISO 8601 和 RFC 3339 日期格式有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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