1

I have the problem that when I send my json-object to my API, the DateTime is reset by one hour. I already read that I should use DateTimeOffset. I did that too, but I get the same result. An example of what my object looks like:

{
    "Person": {
        "Birthday": "2000-01-26T00:00:00+01:00"
    }
}

So everything is correct, but as soon as the object is transferred to the API, the object looks like this:

{
    "Person": {
        "Birthday": "2000-01-25T23:00:00+00:00"
    }
}

To get the data I saved it like this:

Person person = new Person
{
  Birthday = DateTimeOffset.Parse(row["Birthday"].ToString())
}
Hadda
  • 47
  • 2
  • 12
  • All times are in Utc, see https://stackoverflow.com/questions/16697346/datetime-json-return-from-webapi-with-default-serializer – Ralph Willgoss Jan 26 '18 at 09:33
  • Read the similar question at https://stackoverflow.com/questions/13933654/convert-utc-datetime-to-datetimeoffset – Jo Paul Jan 26 '18 at 09:42
  • So I need the ISO8601 Format which look like this: `2000-01-26T00:00:00Z`? – Hadda Jan 26 '18 at 10:52

0 Answers0