-1

I am getting passed date variables from facebook api as a string like this:

2014-05-15T20:36:03+0000

Is that a set format that I can convert directly into a DateTime object or do I have to break apart the string?

Guerrilla
  • 13,375
  • 31
  • 109
  • 210
  • `DateTime dt = Convert.ToDateTime("2014-05-15T20:36:03+0000");` this should do it – Habib May 16 '14 at 16:54
  • It did indeed! Thank you very much – Guerrilla May 16 '14 at 16:56
  • 1
    @Guerrilla - Watch the offset. If you just use `Convert.ToDateTime` or `DateTime.Parse` without any arguments, the resulting `DateTime` will adjust the time based on that offset using your local computer's time zone. The better approach is to parse as a `DateTimeOffset` (see the duplicate). You can take the `DateTime` from there if you like. – Matt Johnson-Pint May 16 '14 at 17:09

1 Answers1

2

You will have to parse the string to a datetime object.

DateTime.Parse("2014-05-15T20:36:03+0000")
bobthedeveloper
  • 3,733
  • 2
  • 15
  • 31