Is there a publicly available API that does time zone conversion?
Does anyone provi开发者_Python百科de an 3rd party API that does time zone conversions? I'm thinking of doing it for a site, just to make it easier to handle all the intricacies. It is a multi-zone scheduling kind of applicaiton and time zones need to be handled perfectly.
I dont think timeanddate.com does it, but does anyone else? Reliabily?
I found a few just searching on google, such as this one:
http://worldtimeengine.com/api/instructions
There seem to be some for a variety of languages, it depends on your need I guess as I'm not sure if you are trying to do it based on city or what
I really want a simple function where I give it a certain time and date (in a timezone) and tell it what timezone I want it in - and it should give me the exact date and time in the target zone! Yes of course this is possible internally, but I fear getting it wrong!
Then you need to test, test and test more. If you're outsourcing because you're afraid of programming you should just buy some software. ;P
The function itself is simple enough.
http://php.net/manual/en/datetime.settimezone.php
function convertTimeZone($time, $origin, $target) {
$date = new DateTime($time, new DateTimeZone($origin));
$date->setTimezone(new DateTimeZone($target));
return $date->format('Y-m-d H:i:s');
}
echo convertTimeZone('2000-01-01 00:00:00', 'Pacific/Nauru', 'Pacific/Chatham');
While googling I found this API Service- www.timezdb.com. It just takes parameters as latitude, longitude, city name, state, country name. I don't know what exactly you require, but just you can visit and see if it could solve your purpose.
Something I made a while ago gives you all timezones, their current time, and if DST is active there or not:
http://api.coronatus.com/clock/read
You can use the utc_offset
field to do timezone conversions.
精彩评论