Convert.ToDateTime returns the previous day

2

Using C #, when I run this:

Convert.ToDateTime("Wed, 20 May 2015 01:36:39 +0000")

It returns me this:

{19/05/2015 22:36:39}
    Date: {19/05/2015 00:00:00}

How do you return it to the correct value?

    
asked by anonymous 20.05.2015 / 15:48

1 answer

1

It seems like Convert.ToDateTime is converting the original date to UTC for a local date.

Checks whether Kind property equals DateTimeKind.Local .

If it is, you have to convert the date to UTC again

date = date.ToUniversalTime();
    
20.05.2015 / 15:54