What's wrong with this date behavior in C#?
Posted
by Jane McDowell
on Stack Overflow
See other posts from Stack Overflow
or by Jane McDowell
Published on 2010-04-15T14:35:58Z
Indexed on
2010/04/15
14:43 UTC
Read the original article
Hit count: 327
If I output a formatted date as follows:
DateTime.Parse("2010-06-02T15:26:37.789 +01:00").ToString("HH:mm:sszzz")
I get the expected result:
15:26:37+01:00
However, if I parse the same date, convert to UTC and output with the same format as follows:
DateTime.Parse("2010-06-02T15:26:37.789 +01:00").ToUniversalTime().ToString("HH:mm:sszzz")
I get this:
14:26:37+01:00
Now those two dates, the local and UTC versions, should be exactly the same but the outputted text represents two different times.
Why is this?
© Stack Overflow or respective owner