Timezone API
The Timezone API provides time offset data for locations on the surface of the earth.
Request
Request Format
Requests can be sent to any of the following endpoints
Region 1: US
https://us1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat=LATITUDE&lon=LONGITUDE
Region 2: Europe
https://eu1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat=LATITUDE&lon=LONGITUDE
Request Example
<?php
$curl = curl_init('https://us1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat=LATITUDE&lon=LONGITUDE');
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
import requests
url = "https://us1.locationiq.com/v1/timezone"
data = {
'key': 'YOUR_ACCESS_TOKEN',
'lat': 'LATITUDE',
'lon': 'LONGITUDE'
}
response = requests.get(url, params=data)
print(response.text)
var settings = {
"async": true,
"crossDomain": true,
"url": "https://us1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat=LATITUDE&lon=LONGITUDE",
"method": "GET"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
curl --request GET \
--url 'https://us1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat=LATITUDE&lon=LONGITUDE'
Request Parameters
Name | Description | Required |
---|---|---|
key | Authentication key | Yes |
lat | Latitude of the location | Yes |
lon | Longitude of the location | Yes |
Response
Response Example
{
"timezone": {
"name": "Asia/Kolkata",
"now_in_dst": 0,
"offset_sec": 19800,
"short_name": "IST"
}
}
Response Parameters
Name | Description |
---|---|
timezone | Timezone object found for the location. |
Timezone object
Name | Description |
---|---|
short_name | Short name of the Timezone |
offset_sec | The offset from UTC (in seconds) for the given location. Considers DST savings. |
now_in_dst | Represents whether the zone currently observing DST or not |
name | Timezone name of the Location |
Updated 9 days ago