Get Indian Standard Time(IST) in c#?

前端 未结 3 1999
野性不改
野性不改 2020-12-31 06:26

When i display my system date using DateTime.Now() function It gives me system date and time and works fine but when i try to run this page on my server it give

3条回答
  •  春和景丽
    2020-12-31 06:56

    Put:

    private static TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
    

    as a field.

    Then, use:

    DateTime indianTime =  TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
    

    to get the time as needed.

提交回复
热议问题