Friday, July 16, 2010

Get Indian Standard Time(IST) in c#

When you are hosting you application to a production server outside india, its often we need indian time so i ve created a c# method which returns indian standard time from your server wherever it is located in india...


public DateTime getIndianStandardTime()
{
 TimeZoneInfo IND_ZONE=TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
 return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE);}

5 comments:

  1. It's working fine.Thanks.

    ReplyDelete
  2. in one like also works as DateTime.UtcNow.AddHours(5.5).ToString()

    ReplyDelete
  3. Its really working fine.Thanks.

    ReplyDelete
  4. Does it Handle DayLight Saving? Not applicable for India but for other countries?

    ReplyDelete