Comparing date and time from GMT to other (eastern, mountain, pacific, indian, ..) formats

I need to know how to convert date time in timezone format to other formats, such as timezone formats in East, Pacific, Mountain and Indian .. in C #, asp.net2.0 and dot net frame work 2.0.

Thanks at Advance

Rupa.

+3
source share
3 answers

Really, you want .NET 3.5 for this ...

(I know what you asked about .NET 2.0, but this answer might be tempting for someone looking for this question in the future)

TimeZoneInfo mountain = TimeZoneInfo.FindSystemTimeZoneById(
    "US Mountain Standard Time");
DateTime utc = DateTime.UtcNow;
DateTime local = TimeZoneInfo.ConvertTimeFromUtc(utc, mountain);

Before that ... pain. You can save your own list of offsets, but then you need to worry about DST.

+1
source

.NET 2.0, , , . P/Invoke TimeZone. .NET 3.5 - TimeZoneInfo . , , , , , DST.

, GetTimeZoneInformation, . , P/Invoke, ... .

.NET 2.0? .NET 3.5...

+2

, , , .

public DateTime IndianStandard(DateTime currentDate)
{
    TimeZoneInfo mountain = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
    DateTime utc = currentDate;
    return TimeZoneInfo.ConvertTimeFromUtc(utc, mountain);
}
0
source

Source: https://habr.com/ru/post/1714771/


All Articles