I am currently working on a c# application and am using an epoch time stamp and converting it back into a normal date and time. This is pretty much working except at the moment it is returning the time as 1 hour behind as it is not taking the daylight saving into account. How can I find out if the user is in a timezone with daylight saving and correct the time as required.
Thanks for any help you can provide.
You haven’t specified how you convert from an epoch time stamp to a
DateTimebut the epoch time stamp is the number of seconds elapsed since 1970-01-01 00:00:00 UTC so I assume you have a UTCDateTime. You can convert this into a local time stamp taking daylight savings into account using this code:It is important that the
Kindof theDateTimeisn’tLocal. If that is not the case you can modify it yourself:On Windows the conversion is based on the timezone and daylight savings settings of the current user executing the code.