• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1478
  • Last Modified:

World Clock

I need to display times for 6 locations around the world on a local server, including the current time where the web server sits.
I also need to adjust for DST.

Is there a straight-forward way of doing this?
  • 3
1 Solution
Dave BaldwinFixer of ProblemsCommented:
Here's a link to info about 'tzdata', a public domain time info database: http://en.wikipedia.org/wiki/Tz_database   I don't find a link to C# code right off but there probably is sample code somewhere.  tzdata is frequently updated.
I would try to use an existing web service that provides that functionality. There is a free one with sample code here. http://www.csharphelp.com/2006/10/consuming-a-web-service-in-c/

If you only need 6 locations and not the whole world, then maybe this is project will get you started. http://www.codeproject.com/KB/selection/3ZoneWorldClock.aspx
devo00Author Commented:
Even with improvements in ASP.NET 3.5, it's this involved?
devo00Author Commented:
This 'seems' to be the answer I'm looking for, does not require the larger efforts noted above, and accommodates DST:

Using the .NET 3.5 TimeZoneInfo object:

DateTime oldTime = new DateTime(2007, 6, 23, 10, 0, 0);
TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime newTime = TimeZoneInfo.ConvertTime(oldTime, timeZone1, timeZone2);

Open in new window

Chris Pietschmann
devo00Author Commented:
Found a good, succinct, working solution in my own search efforts.

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now