Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert facebook Graph date time into c# DateTime

Tags:

c#

facebook

I have "2010-12-20T11:36:28+0000". How do I parse it into DateTime?

Thanks

like image 635
Himberjack Avatar asked Dec 20 '10 12:12

Himberjack


2 Answers

DateTime d = DateTime.Parse("2010-12-20T11:36:28+0000");

Works on my machine and parses time zone.

like image 165
Tim Lloyd Avatar answered Nov 16 '22 00:11

Tim Lloyd


You can use ParseExact or TryParseExact with a Custom Date and Time Format String.

Tested:

var myDate = DateTime.ParseExact("2010-12-20T11:36:28+0000", 
                                 @"yyyy-MM-dd\THH:mm:ssK",
                                 CultureInfo.InvariantCulture);

Having said that, DateTime.Parse works perfectly well.

like image 29
Oded Avatar answered Nov 16 '22 01:11

Oded