Reputation: 38555
I get a json date from a webservice that i need to parse manualy and the date looks like this: "Fri, 06 Nov 2009 00:00:00 -0800"
How would i parse this into a datetime object?
I guess i should use DateTime.ParseExact but what do i feed into it.
Upvotes: 3
Views: 4609
Reputation: 24488
// parse JSON formatted date to javascript date object
var date = new Date(parseInt(jsonDate.substr(6)));
// format display date (e.g. 04/10/2012)
THEN
var displayDate = $.datepicker.formatDate("mm/dd/yy", date);
from http://blog.degree.no/bloggere/
Upvotes: 0
Reputation: 9146
I ran this code and it worked fine:
string date = "Fri, 06 Nov 2009 00:00:00 -0800";
DateTime dt = DateTime.Parse(date);
Upvotes: 1
Reputation: 59002
var date = DateTime.Parse("Fri, 06 Nov 2009 00:00:00 -0800");
works fine.
Upvotes: 2