tags:

views:

115

answers:

4

I'd like to use date time format string (possibly UTC) which is understandable and parsable on as many platforms and languages as possible? At least PHP, Python, Perl, Java, Rails and some common C++ library should be able to understand it.

Which one should I use?

Sample from 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
+6  A: 

Stick with ISO8601 and you can't go wrong.

Preferably, YYYYMMDD HH:mm:ss [TZ] format as it is the most widely used.

And definitely UTC "under the covers" if you are decoupling local time at the presentation layer of the application from internal stored time.

Rob Wells
+2  A: 

I'd go with ISO 8601 also, or simply the (unix_time ??) format which is number of seconds since 00:00 on 01/01/1970 - you can always parse it to get the desired time (even if it is a little more effort)

Ken Hughes
+3  A: 

ISO 8601 is the way to go. See this document for a useful introduction. You'll want to specify the time zone along with the date/time, I would suggest.

Brian Agnew
+3  A: 

The round-trip formats are ISO 8601 compliant. I would use them.

LukeH