Get the time of any city. API

Reading function (required)

Use the following function (or similar) to get the API data

    
List of cities covered

Option Name_of_the_City

The call
    
    get_the_time_in("New_York",MyCallback)
    

Returns the following object

     
timezoneOffset is the time difference between the city and UTC in seconds.

Option list

The call
    
    get_the_time_in("list",MyCallback)
    

Returns the following object that contains the list of contemplated cities with their timezone information

    

Example 1 Time in Shanghai

HTML
    
<div id="ShanghaiTime"></div>
    
JS

    

Example 2 Create city-timezoneOffset selector

HTML
    
<select id="selectorCity"></select>
<div id="dateTimeCity"></div>
    
JS

    

Annex: Valid city names for this API

Note: If your city is not on the list, choose a nearby one with the same time slot.

Credits

PHP logo
The data is obtained from the PHP DateTime class

Links


Index of sections