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
Post a Comment