How to Get Datetime Wrt Time Zone in C#

  public static DateTime GetDateTime()

  {

//here we are trying to get the indian datetime irrespective of hosted server location

            TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

            DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZoneInfo);

            return now;

  }

Comments

Popular posts from this blog

Top MNC Interview Questions- Full Stack Developer

Interview Questions-2

How to get the user details, user current level, next level, Rank in sql server