Reference: Get Time Zone

http://api.timezonedb.com/v2/get-time-zone

Get local time of a city by its name, time zone, latitude & longtiude, or IP address.

Other End Points

Parameters

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, dstStart, dstEnd, nextAbbreviation, timestamp, formatted
DEFAULT: all
by
REQUIRED
The method of lookup.
  • zone - Lookup local time by using a time zone name.
  • position - Lookup local time by using latitude & longitude of a city.
  • PREMIUM
    city - Lookup time zone by searching city name.
  • PREMIUM
    ip - Lookup time zone based on visitor IP address.
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 25 records.
time
OPTIONAL
Unix time in UTC.

DEFAULT: Current UTC time.

Responses

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.
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).
dstStart The Unix time in UTC when current time zone start.
dstEnd 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.: 2018-07-19 04:02:48
totalPage The total page of result when exceed 25 records.
currentPage Current page when navigating.

Usage Examples

Get current local time in Chicago, USA

Query
http://api.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=xml&by=zone&zone=America/Chicago
Response
<?xml version="1.0" encoding="UTF-8"?>
<result>
	<status>OK</status>
	<message/>
	<countryCode>US</countryCode>
	<countryName>United States</countryName>
	<zoneName>America/Chicago</zoneName>
	<abbreviation>CST</abbreviation>
	<gmtOffset>-21600</gmtOffset>
	<dst>0</dst>
	<dstStart>1446361200</dstStart>
	<dstEnd>1457856000</dstEnd>
	<nextAbbreviation>CDT</nextAbbreviation>
	<timestamp>1454446991</timestamp>
	<formatted>2016-02-02 21:03:11</formatted>
</result>
Query
http://api.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=json&by=zone&zone=America/Chicago
Response
{
	"status":"OK",
	"message":"",
	"countryCode":"US",
	"countryName":"United States",
	"zoneName":"America\/Chicago",
	"abbreviation":"CST",
	"gmtOffset":-21600,
	"dst":"0",
	"dstStart":1446361200,
	"dstEnd":1457856000,
	"nextAbbreviation":"CDT",
	"timestamp":1454446991,
	"formatted":"2016-02-02 21:03:11"
}

 

Get current local time in Taipei, Taiwan when UTC is 24 December, 2015 11:50:55 PM

Query
http://api.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=xml&by=zone&zone=Asia/Taipei&time=1451001055
Response
<?xml version="1.0" encoding="UTF-8"?>
<result>
	<status>OK</status>
	<message/>
	<countryCode>TW</countryCode>
	<countryName>Taiwan</countryName>
	<zoneName>Asia/Taipei</zoneName>
	<abbreviation>CST</abbreviation>
	<gmtOffset>28800</gmtOffset>
	<dst>0</dst>
	<dstStart>307551600</dstStart>
	<dstEnd>0</dstEnd>
	<nextAbbreviation/>
	<timestamp>1451029855</timestamp>
	<formatted>2015-12-25 07:50:55</formatted>
</result>
Query
http://api.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=json&by=zone&zone=Asia/Taipei&time=1451001055
Response
{
	"status":"OK",
	"message":"",
	"countryCode":"TW",
	"countryName":"Taiwan",
	"zoneName":"Asia\/Taipei",
	"abbreviation":"CST",
	"gmtOffset":28800,
	"dst":"0",
	"dstStart":307551600,
	"dstEnd":0,
	"nextAbbreviation":"",
	"timestamp":1451029855,
	"formatted":"2015-12-25 07:50:55"
}

 

Get local time zone for City of Buffalo in US

Query
http://vip.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=xml&by=city&city=City+of+Buffalo&country=US
Response
<?xml version="1.0" encoding="UTF-8"?>
<result>
	<status>OK</status>
	<message/>
	<totalPage>1</totalPage>
	<currentPage>1</currentPage>
	<zones>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>Iowa</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/Chicago</zoneName>
			<abbreviation>CST</abbreviation>
			<gmtOffset>-21600</gmtOffset>
			<dst>0</dst>
			<dstStart>1320562800</dstStart>
			<timestamp>1321195745</timestamp>
			<formatted>2011-11-13 14:49:05</formatted>
			<dstEnd>1331452800</dstEnd>
			<nextAbbreviation>CDT</nextAbbreviation>
		</zone>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>Kansas</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/Chicago</zoneName>
			<abbreviation>CST</abbreviation>
			<gmtOffset>-21600</gmtOffset>
			<dst>0</dst>
			<dstStart>1320562800</dstStart>
			<timestamp>1321195745</timestamp>
			<formatted>2011-11-13 14:49:05</formatted>
			<dstEnd>1331452800</dstEnd>
			<nextAbbreviation>CDT</nextAbbreviation>
		</zone>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>Missouri</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/Chicago</zoneName>
			<abbreviation>CST</abbreviation>
			<gmtOffset>-21600</gmtOffset>
			<dst>0</dst>
			<dstStart>1320562800</dstStart>
			<timestamp>1321195745</timestamp>
			<formatted>2011-11-13 14:49:05</formatted>
			<dstEnd>1331452800</dstEnd>
			<nextAbbreviation>CDT</nextAbbreviation>
		</zone>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>North Dakota</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/Chicago</zoneName>
			<abbreviation>CST</abbreviation>
			<gmtOffset>-21600</gmtOffset>
			<dst>0</dst>
			<dstStart>1320562800</dstStart>
			<timestamp>1321195745</timestamp>
			<formatted>2011-11-13 14:49:05</formatted>
			<dstEnd>1331452800</dstEnd>
			<nextAbbreviation>CDT</nextAbbreviation>
		</zone>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>New York</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/New_York</zoneName>
			<abbreviation>EST</abbreviation>
			<gmtOffset>-18000</gmtOffset>
			<dst>0</dst>
			<dstStart>1320559200</dstStart>
			<timestamp>1321199345</timestamp>
			<formatted>2011-11-13 15:49:05</formatted>
			<dstEnd>1331449200</dstEnd>
			<nextAbbreviation>EDT</nextAbbreviation>
		</zone>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>Texas</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/Chicago</zoneName>
			<abbreviation>CST</abbreviation>
			<gmtOffset>-21600</gmtOffset>
			<dst>0</dst>
			<dstStart>1320562800</dstStart>
			<timestamp>1321195745</timestamp>
			<formatted>2011-11-13 14:49:05</formatted>
			<dstEnd>1331452800</dstEnd>
			<nextAbbreviation>CDT</nextAbbreviation>
		</zone>
		<zone>
			<countryCode>US</countryCode>
			<countryName>United States</countryName>
			<regionName>Wyoming</regionName>
			<cityName>City of Buffalo</cityName>
			<zoneName>America/Denver</zoneName>
			<abbreviation>MST</abbreviation>
			<gmtOffset>-25200</gmtOffset>
			<dst>0</dst>
			<dstStart>1320566400</dstStart>
			<timestamp>1321192145</timestamp>
			<formatted>2011-11-13 13:49:05</formatted>
			<dstEnd>1331456400</dstEnd>
			<nextAbbreviation>MDT</nextAbbreviation>
		</zone>
	</zones>
</result>
Query
http://vip.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=json&by=city&city=City+of+Buffalo&country=US
Response
{
	"status":"OK",
	"message":"",
	"zones":[
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"Iowa",
			"cityName":"City of Buffalo",
			"zoneName":"America\/Chicago",
			"abbreviation":"CST",
			"gmtOffset":-21600,
			"dst":"0",
			"dstStart":1320562800,
			"timestamp":1321195745,
			"formatted":"2011-11-13 14:49:05",
			"dstEnd":1331452800,
			"nextAbbreviation":"CDT"
		},
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"Kansas",
			"cityName":"City of Buffalo",
			"zoneName":"America\/Chicago",
			"abbreviation":"CST",
			"gmtOffset":-21600,
			"dst":"0",
			"dstStart":1320562800,
			"timestamp":1321195745,
			"formatted":"2011-11-13 14:49:05",
			"dstEnd":1331452800,
			"nextAbbreviation":"CDT"
		},
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"Missouri",
			"cityName":"City of Buffalo",
			"zoneName":"America\/Chicago",
			"abbreviation":"CST",
			"gmtOffset":-21600,
			"dst":"0",
			"dstStart":1320562800,
			"timestamp":1321195745,
			"formatted":"2011-11-13 14:49:05",
			"dstEnd":1331452800,
			"nextAbbreviation":"CDT"
		},
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"North Dakota",
			"cityName":"City of Buffalo",
			"zoneName":"America\/Chicago",
			"abbreviation":"CST",
			"gmtOffset":-21600,
			"dst":"0",
			"dstStart":1320562800,
			"timestamp":1321195745,
			"formatted":"2011-11-13 14:49:05",
			"dstEnd":1331452800,
			"nextAbbreviation":"CDT"
		},
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"New York",
			"cityName":"City of Buffalo",
			"zoneName":"America\/New_York",
			"abbreviation":"EST",
			"gmtOffset":-18000,
			"dst":"0",
			"dstStart":1320559200,
			"timestamp":1321199345,
			"formatted":"2011-11-13 15:49:05",
			"dstEnd":1331449200,
			"nextAbbreviation":"EDT"
		},
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"Texas",
			"cityName":"City of Buffalo",
			"zoneName":"America\/Chicago",
			"abbreviation":"CST",
			"gmtOffset":-21600,
			"dst":"0",
			"dstStart":1320562800,
			"timestamp":1321195745,
			"formatted":"2011-11-13 14:49:05",
			"dstEnd":1331452800,
			"nextAbbreviation":"CDT"
		},
		{
			"countryCode":"US",
			"countryName":"United States",
			"regionName":"Wyoming",
			"cityName":"City of Buffalo",
			"zoneName":"America\/Denver",
			"abbreviation":"MST",
			"gmtOffset":-25200,
			"dst":"0",
			"dstStart":1320566400,
			"timestamp":1321192145,
			"formatted":"2011-11-13 13:49:05",
			"dstEnd":1331456400,
			"nextAbbreviation":"MDT"
		}
	]
}

 

Get time zone by IP address with custom fields

Query
http://vip.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=xml&by=ip&ip=66.249.64.135&fields=countryCode,cityName,gmtOffset,dst
Response
<?xml version="1.0" encoding="UTF-8"?>
<result>
	<status>OK</status>
	<message/>
	<countryCode>US</countryCode>
	<cityName>Mountain View</cityName>
	<gmtOffset>-25200</gmtOffset>
	<dst>1</dst>
</result>
Query
http://vip.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY&format=json&by=ip&ip=66.249.64.135&fields=countryCode,cityName,gmtOffset,dst
Response
{
	"status":"OK",
	"message":"",
	"countryCode":"US",
	"cityName":"Mountain View",
	"gmtOffset":-25200,
	"dst":"1"
}