Get current time of any country

//To find out the current time in any country, factoring in Daylight saving, we can use the following code

/* We generate all the timezones so we can pick as and when necessary */
public static readonly ReadOnlyCollection<TimeZoneInfo> TimeZones = TimeZoneInfo.GetSystemTimeZones();

/* Get the timezone of the exchange currently in operation */
TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById(“Indian Standard Time”);

/* Get the offset */
var dto = DateTimeOffset.UtcNow;

/*Now get the current time for the exchange */
var currentTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dto, info.Id);


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s