I want to calculate the current time differences between US/Central timezone and British Summer Time. I mean, currently these both timezones have daylight savings going on, so they have a 6 hours time difference. But after Sunday October 31 2010, daylight savings will be off for British summer time, at which moment there will be a 5 hours time differences between these two timezones.
Is there any way I can calculate these varying time differences?
As a general rule of thumb, a change of 15° of longitude should result in a time difference of 1 hour. In the U.S., there are a total of 9 time zones used. Likely the most well-known include Eastern, Central, Mountain, and Pacific Time Zones.
Calculate the duration between two times The goal is to subtract the starting time from the ending time under the correct conditions. If the times are not already in 24-hour time, convert them to 24-hour time. AM hours are the same in both 12-hour and 24-hour time.
Just to provide some concrete code for the answers given, here's some code to work out the current difference between me (in London) and my colleagues in Mountain View:
using System;
class Test
{
static void Main()
{
var london = TimeZoneInfo.FindSystemTimeZoneById
("GMT Standard Time");
var googleplex = TimeZoneInfo.FindSystemTimeZoneById
("Pacific Standard Time");
var now = DateTimeOffset.UtcNow;
TimeSpan londonOffset = london.GetUtcOffset(now);
TimeSpan googleplexOffset = googleplex.GetUtcOffset(now);
TimeSpan difference = londonOffset - googleplexOffset;
Console.WriteLine(difference);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With