Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  25] [ 3]  / answers: 1 / hits: 29101  / 15 Years ago, mon, july 6, 2009, 12:00:00

What is a culture-invariant way of constructing a string such that the Javascript Date() constructor can parse it and create the proper date object?



I have tried these format strings which don't work (using C# to generate the strings):



clientDate.ToString();
// gives: 11/05/2009 17:35:23 +00:00

clientDate.ToString(MMM' 'dd', 'yyyy' 'h':'mm':'ss' 'tt);
// works on an English server
// but on a French server, gives: mai 11, 2009 5:35:23
// Javascript won't parse that.

clientDate.ToString(MM'-'dd'-'yyyy' 'HH':'mm':'ss)
// gives: 05-11-2009 17:35:23


What is the universal format??


More From » parsing

 Answers
5

According to MDC:



Given a string representing a time, parse returns the time value. It accepts the IETF standard (RFC 1123 Section 5.2.14 and elsewhere) date syntax: "Mon, 25 Dec 1995 13:30:00 GMT". It understands the continental US time-zone abbreviations, but for general use, use a time-zone offset, for example, "Mon, 25 Dec 1995 13:30:00 GMT+0430" (4 hours, 30 minutes east of the Greenwich meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are considered equivalent.



If you can’t generate this format using english locale, try to use Date.UTC


[#99182] Wednesday, July 1, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brodyfrancisi

Total Points: 1
Total Questions: 102
Total Answers: 89

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
brodyfrancisi questions
;