开发者

c# Parse json Date?

开发者 https://www.devze.com 2022-12-08 19:47 出处:网络
I get a json date from a webservice that i need to parse manualy and the date looks开发者_StackOverflow like this:

I get a json date from a webservice that i need to parse manualy and the date looks开发者_StackOverflow 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.


Just use DateTime.Parse. I verified it works for this string.


var date = DateTime.Parse("Fri, 06 Nov 2009 00:00:00 -0800"); works fine.


I ran this code and it worked fine:

string date = "Fri, 06 Nov 2009 00:00:00 -0800";
DateTime dt = DateTime.Parse(date);


Check it out: Converting String to DateTime C#.net


// 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/

0

精彩评论

暂无评论...
验证码 换一张
取 消