If I run:
// 7:10 am at a location which has a +2 offset from UTC
string timeString = "2011-06-15T07:10:25.894+02:00";
DateTime time = DateTime.Parse(timeString);
It gives me time = 6/14/2011 10:10:25 PM. This is the local time where I am at (Pacific time i.e. UTC -7).
Is there an elegant way of getting the local time at the origin i.e. 6/15/2011 07:10:25 AM?
The
DateTimeOffsetstructure seems to be built to specifically handle timezones. It includes most of the functionality of theDateTimetype.As this article illustrates, you should
DateTimeOffsetinstead ofDateTimewhenever you need to unambiguously identify a single point in time.