i have hosted a site on a server that have different time zone than my local country,
how can I convert the server time to my local time with taking into consideration the Daylight Saving
DateTimeOffset newTime = TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("AppTimeZone"));
to blatantly take answers from other SO questions:
In .NET 3.5, there is TimeZoneInfo, which provides a lot of functionality in this area; 2.0SP1 has DateTimeOffset, but this is much more limited.
See the following SO questions:
Get DateTime For Another Time Zone Regardless of Local Time Zone
Convert UTC DateTime to another Time Zone
Or just search SO for a lot of answers including some that take into consideration Daylight Savings.
Have you looked at the TimeZoneInfo
class. You should be able to convert to and from local to server time through there whilst maintaining DST.
There is also an Open Source time zone implementation by Jon Skeet et. al call Noda-Time.