Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  70] [ 5]  / answers: 1 / hits: 33155  / 15 Years ago, wed, december 9, 2009, 12:00:00

I have javascript date object which gives me a date string in this format, Wed Dec 16 00:00:00 UTC-0400 2009.



I pass this via Ajax to the server (ASP.NET c#)



How can I convert, Wed Dec 16 00:00:00 UTC-0400 2009 to a C# DateTime object. DateTime.Parse fails.


More From » c#

 Answers
35

You can use DateTime.ParseExact which allows you to specify a format string to be used for parsing:



DateTime dt = DateTime.ParseExact(Wed Dec 16 00:00:00 UTC-0400 2009,
ddd MMM d HH:mm:ss UTCzzzzz yyyy,
CultureInfo.InvariantCulture);

[#98107] Sunday, December 6, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
payne

Total Points: 527
Total Questions: 108
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;