Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
2.40/5 (2 votes)
See more:
Hi All,

I want to get current time of the country on the basis of passing country name.
I did googling but not got respective result.


Please help me , if you can provide a solution or any address of a web service.


Thanks
Posted

If you trust your own computer's system clock, you can use TimeZoneInfo.ConvertTime[^]

If not, have a look at Google Time Zone API[^]. I have not used it myself, but it looks promising.
 
Share this answer
 
Comments
ridoy 20-Sep-13 5:31am    
5ed!
You can't in practice do that: a country may be in several time zones (Russia is in nine time zones, and the USA is in six for example).

You are much better off looking at a list of time zones (which is what Windows uses) and the calling the TimeZoneInfo.ConvertTime method:
C#
DateTime now = DateTime.Now;
DateTime usaEST = TimeZoneInfo.ConvertTime(now, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
Console.WriteLine(usaEST);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900