How to find the current time of any city in the world with PHP?

date, php, time

Solution

You're going to need a database containing time zone information for every city that is to be queried, and then make a time zone adjustment to your current server time.

There is a Time Zone database located here. It looks like it comes with some C code to dump the time zone information to a file that, hopefully, is importable to a database table. Once you have that, you should be able to get a time zone adjustment for any city in the world, at any time of the year.

Problem

For example, I would be able to type a function like so: ``` echo findtimeinworld('<some way to format Sydney, Australia>'); // The current time in Sydney, Australia in a timestamp ``` How would such a function be possible? Also, please note I'm working on a hosted server here, so the server time may be anything. Bonus votes for the smallest possible function.

Original source