我想使用在尽可能多的平台和语言上可以理解和解析的日期时间格式字符串(可能是 UTC)?至少PHP、Python、Perl、Java、Rails和一些常用的C++库应该能看懂。
我应该使用哪一个?
来自 MSDN 的示例:
Culture: English (United States)
(d) Short date: . . . . . . . 4/17/2006
(D) Long date:. . . . . . . . Monday, April 17, 2006
(t) Short time: . . . . . . . 2:29 PM
(T) Long time:. . . . . . . . 2:29:09 PM
(f) Full date/short time: . . Monday, April 17, 2006 2:29 PM
(F) Full date/long time:. . . Monday, April 17, 2006 2:29:09 PM
(g) General date/short time:. 4/17/2006 2:29 PM
(G) General date/long time (default):
. . . . . . . . . . . . . 4/17/2006 2:29:09 PM
(M) Month:. . . . . . . . . . April 17
(R) RFC1123:. . . . . . . . . Mon, 17 Apr 2006 21:29:09 GMT
(s) Sortable: . . . . . . . . 2006-04-17T14:29:09
(u) Universal sortable (invariant):
. . . . . . . . . . . . . 2006-04-17 21:29:09Z
(U) Universal full date/time: Monday, April 17, 2006 9:29:09 PM
(Y) Year: . . . . . . . . . . April, 2006
(o) Roundtrip (local):. . . . 2006-04-17T14:29:09.3011250-07:00
(o) Roundtrip (UTC):. . . . . 2006-04-17T21:29:09.3011250Z
(o) Roundtrip (Unspecified):. 2000-03-20T13:02:03.0000000
最佳答案
坚持使用 ISO8601 就不会出错。
最好是 YYYYMMDD HH:mm:ss [TZ] 格式,因为它使用最广泛。
如果您在应用程序的表示层将本地时间与内部存储时间分离,那么肯定是 UTC“在幕后”。
关于c# - 哪种日期和时间格式与其他平台最兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1092075/