Reference: Get Time Zone
http://api.timezonedb.com/v2.1/get-time-zone
Get local time of a city by its name, time zone, latitude & longtiude, or IP address.
Other End Points
http://api.timezonedb.com/v2.1/get-time-zone
Get local time of a city by its name, time zone, latitude & longtiude, or IP address.
Parameter | Description |
key | REQUIRED Your unique API key you get after register your account. |
format |
OPTIONAL The response format from API. It can be either xml or json.
DEFAULT: xml |
callback | OPTIONAL Use for JavaScript JSON callback. |
fields |
OPTIONAL Customize the field to display in response. Use commas ("," without spaces) to separate the field names.
FIELDS: countryCode, countryName, regionName, cityName, zoneName, abbreviation, gmtOffset, dst, zoneStart, zoneEnd, nextAbbreviation, timestamp, formatted DEFAULT: all |
by |
REQUIRED The method of lookup.
|
zone | REQUIRED A time zone abbreviation or time zone name. Required if lookup by zone method. |
lat | REQUIRED Latitude of a city. Required if lookup by position method. |
lng | REQUIRED Longitude of a city. Required if lookup by position method. |
country | REQUIRED A valid ISO 3166 country code. Required if lookup by city method. |
region | OPTIONAL A valid region code of United States. Optional when lookup by city method to limit the search result. |
city | REQUIRED The name of a city. Use asterisk (*) for wildcard search. Required if lookup by city method. |
page | OPTIONAL Navigate to other page when result is more than 10 records. |
time |
OPTIONAL Unix time in UTC.
DEFAULT: Current UTC time. |
Field | Description |
status | Status of the API query. Either OK or FAILED. |
message | Error message. Empty if no error. |
countryCode | Country code of the time zone. |
countryName | Country name of the time zone. |
regionName | PREMIUM Region / State name of the time zone. |
cityName | PREMIUM City / Place name of the time zone. |
zoneName | The time zone name. |
abbreviation | Abbreviation of the time zone. |
gmtOffset | The time offset in seconds based on UTC time. |
dst | Whether Daylight Saving Time (DST) is used. Either 0 (No) or 1 (Yes). |
zoneStart | The Unix time in UTC when current time zone start. |
zoneEnd | The Unix time in UTC when current time zone end. |
timestamp | Current local time in Unix time. Minus the value with gmtOffset to get UTC time. |
formatted | Formatted timestamp in Y-m-d h:i:s format. E.g.: 2022-05-22 05:20:27 |
totalPage | The total page of result when exceed 25 records. |
currentPage | Current page when navigating. |
http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=xml&by=position&lat=40.689247&lng=-74.044502
<?xml version="1.0" encoding="UTF-8"?> <result> <status>OK</status> <message/> <countryCode>US</countryCode> <countryName>United States of America</countryName> <regionName>New York</regionName> <cityName>Battery Park Ferry Port</cityName> <zoneName>America/New_York</zoneName> <abbreviation>EDT</abbreviation> <gmtOffset>-14400</gmtOffset> <dst>1</dst> <zoneStart>1647154800</zoneStart> <zoneEnd>1667714400</zoneEnd> <nextAbbreviation>EST</nextAbbreviation> <timestamp>1653182427</timestamp> <formatted>2022-05-22 01:20:27</formatted> </result>
http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=json&by=position&lat=40.689247&lng=-74.044502
{ "status": "OK", "message": "", "countryCode": "US", "countryName": "United States of America", "regionName": "New York", "cityName": "Battery Park Ferry Port", "zoneName": "America\/New_York", "abbreviation": "EDT", "gmtOffset": -14400, "dst": "1", "zoneStart": 1647154800, "zoneEnd": 1667714400, "nextAbbreviation": "EST", "timestamp": 1653182428, "formatted": "2022-05-22 01:20:28" }
http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=xml&by=zone&zone=America/Chicago
<?xml version="1.0" encoding="UTF-8"?> <result> <status>OK</status> <message/> <countryCode>US</countryCode> <countryName>United States of America</countryName> <regionName/> <cityName/> <zoneName>America/Chicago</zoneName> <abbreviation>CDT</abbreviation> <gmtOffset>-18000</gmtOffset> <dst>1</dst> <zoneStart>1647158400</zoneStart> <zoneEnd>1667717999</zoneEnd> <nextAbbreviation>CST</nextAbbreviation> <timestamp>1653178828</timestamp> <formatted>2022-05-22 00:20:28</formatted> </result>
http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=json&by=zone&zone=America/Chicago
{ "status": "OK", "message": "", "countryCode": "US", "countryName": "United States of America", "regionName": "", "cityName": "", "zoneName": "America\/Chicago", "abbreviation": "CDT", "gmtOffset": -18000, "dst": "1", "zoneStart": 1647158400, "zoneEnd": 1667717999, "nextAbbreviation": "CST", "timestamp": 1653178828, "formatted": "2022-05-22 00:20:28" }
http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=xml&by=zone&zone=Asia/Taipei&time=1653196829
<?xml version="1.0" encoding="UTF-8"?> <result> <status>OK</status> <message/> <countryCode>TW</countryCode> <countryName>Taiwan, Province of China</countryName> <regionName/> <cityName/> <zoneName>Asia/Taipei</zoneName> <abbreviation>CST</abbreviation> <gmtOffset>28800</gmtOffset> <dst>0</dst> <zoneStart>307551600</zoneStart> <zoneEnd/> <nextAbbreviation/> <timestamp>1653225629</timestamp> <formatted>2022-05-22 13:20:29</formatted> </result>
http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=json&by=zone&zone=Asia/Taipei&time=1653196829
{ "status": "OK", "message": "", "countryCode": "TW", "countryName": "Taiwan, Province of China", "regionName": "", "cityName": "", "zoneName": "Asia\/Taipei", "abbreviation": "CST", "gmtOffset": 28800, "dst": "0", "zoneStart": 307551600, "zoneEnd": null, "nextAbbreviation": null, "timestamp": 1653225629, "formatted": "2022-05-22 13:20:29" }
http://vip.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=xml&by=city&city=City+of+Buffalo&country=US
<?xml version="1.0" encoding="UTF-8"?> <result> <status>FAILED</status> <message>Record not found.</message> <totalPage>1</totalPage> <currentPage>1</currentPage> <zones/> </result>
http://vip.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=json&by=city&city=City+of+Buffalo&country=US
{ "status": "FAILED", "message": "Record not found.", "totalPage": 1, "currentPage": 1, "zones": [] }
http://vip.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=xml&by=ip&ip=3.238.72.122&fields=countryCode,cityName,gmtOffset,dst
<?xml version="1.0" encoding="UTF-8"?> <result> <status>OK</status> <message/> <countryCode>US</countryCode> <cityName>Ashburn</cityName> <gmtOffset>-14400</gmtOffset> <dst>1</dst> </result>
http://vip.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=json&by=ip&ip=3.238.72.122&fields=countryCode,cityName,gmtOffset,dst
{ "status": "OK", "message": "", "countryCode": "US", "cityName": "Ashburn", "gmtOffset": -14400, "dst": "1" }