Linux日期验证:Ubuntu和CentOS之间的差异

4
下面的命令在我的Ubuntu机器上能够运行: $ date -d 2014-07-23T00:00Z
结果为:
ons 23 jul 2014 02:00:00 CEST
然而在另一台运行Centos的机器上我却得到了以下输出: $ date -d 2014-07-23T00:00Z date: invalid date `2014-07-23T00:00Z'
通过运行以下命令,我注意到Ubuntu和Centos机器上的gnu coreutils版本分别为8.21和8.4。
date --version
我的问题是:这是由于日期功能的差异引起的吗?还是与其他原因有关(例如语言环境,我已经尝试过但没有成功)?
如果是由于日期功能的差异导致的,请问在哪里可以阅读有关这些更新的信息?
1个回答

1

来自NEWS文件

* Noteworthy changes in release 8.13 (2011-09-08) [stable]

[..trim..]

** New features

  date now accepts ISO 8601 date-time strings with "T" as the
  separator.  It has long parsed dates like "2004-02-29 16:21:42"
  with a space between the date and time strings.  Now it also parses
  "2004-02-29T16:21:42" and fractional-second and time-zone-annotated
  variants like "2004-02-29T16:21:42.333-07:00"

所以,这是GNU Coreutils 8.13及更高版本中可用的功能。
这个条目也应该给你一个答案,告诉你如何修复你的字符串,使其在两个平台上都能正常工作 :-)

谢谢您的快速回答。我还没有找到那个新闻文件。我尝试了 /usr/share/doc/coreutils 下的 changelog,但没有找到这个宝贵的信息。 - Thomas Larsson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接