Announcement: As of October 4th, 2018 TimezoneAPI will no longer support free plans. Read moreā€¦

close

Timezone API is an extensive time zone API

Working with, and understanding time zones can be a hair pulling experience.
TimezoneAPI makes it easy for you to request an extensive amount of information
about your users based on IP address lookup, address lookup or time zone lookup.

Example: Get information about a user based on IP address

Returns location, timezone and datetime information.

Use your prefered coding language to make the request

$ curl https://timezoneapi.io/api/ip/?66.220.144.0&token=TOKEN
// Get IP address
$ip_address = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');

// Get JSON object
$jsondata = file_get_contents("http://timezoneapi.io/api/ip/?" . $ip_address . '&token=TOKEN');

// Decode
$data = json_decode($jsondata, true);

// Request OK?
if($data['meta']['code'] == '200'){

	// Example: Get the city parameter
	echo "City: " . $data['data']['city'] . "<br>";

	// Example: Get the users time
	echo "Time: " . $data['data']['datetime']['date_time_txt'] . "<br>";

}
// Require
const request = require('request');

// Request
request('https://timezoneapi.io/api/ip/?token=TOKEN', function(err, res, dat){

	// Parse
	var data = JSON.parse(dat);

	// Request OK?
    if(data.meta.code == '200'){

        // Log
        console.log(data);

        // Example: Get the city parameter
        var city = data.data.city;

        // Example: Get the users time
        var time = data.data.datetime.date_time_txt;

    }

});
// Get JSON object
$.getJSON('https://timezoneapi.io/api/ip/?token=TOKEN', function(data){

	// Request OK?
	if(data.meta.code == '200'){

		// Log
		console.log(data);

		// Example: Get the city parameter
		var city = data.data.city;
		alert(city);

		// Example: Get the users time
		var time = data.data.datetime.date_time_txt;
		alert(time);

	}

});
# Require
require 'json'
require 'open-uri'

# Get JSON and parse
data = JSON.parse(open('https://timezoneapi.io/api/ip/?token=TOKEN').read)

# If OK, get values
if data['meta']['code'] = 200
	city = data['data']['city']
	puts city
	time = data['data']['datetime']['date_time_txt']
	puts time
end
# Import
import requests

# Get
response = requests.get('https://timezoneapi.io/api/ip/?token=TOKEN')

# Parse JSON
data = response.json()

# If ok, get values
if data['meta']['code'] = 200:
	City = data['data']['city']
	print City
	Time = data['data']['datetime']['date_time_txt']
	print Time

Returns

{
    "meta": {
        "code": "200"
    },
    "data": {
        "ip": "66.220.144.0",
        "city": "Menlo Park",
        "postal": "94025",
        "state": "California",
        "state_code": "CA",
        "country": "United States",
        "country_code": "US",
        "location": "37.459,-122.1781",
        "timezone": {
            "id": "America\/Los_Angeles",
            "location": "34.05222,-118.24278",
            "country_code": "US",
            "country_name": "United States of America",
            "iso3166_1_alpha_2": "US",
            "iso3166_1_alpha_3": "USA",
            "un_m49_code": "840",
            "itu": "USA",
            "marc": "xxu",
            "wmo": "US",
            "ds": "USA",
            "phone_prefix": "1",
            "fifa": "USA",
            "fips": "US",
            "gual": "259",
            "ioc": "USA",
            "currency_alpha_code": "USD",
            "currency_country_name": "UNITED STATES",
            "currency_minor_unit": "2",
            "currency_name": "US Dollar",
            "currency_code": "840",
            "independent": "Yes",
            "capital": "Washington",
            "continent": "NA",
            "tld": ".us",
            "languages": "en-US,es-US,haw,fr",
            "geoname_id": "6252001",
            "edgar": ""
        },
        "datetime": {
            "date": "12\/05\/2018",
            "date_time": "12\/05\/2018 01:35:13",
            "date_time_txt": "Monday, December 5, 2018 01:35:13",
            "date_time_wti": "Mon, 05 Dec 2018 01:35:13 -0800",
            "date_time_ymd": "2018-12-05T01:35:13-08:00",
            "time": "01:35:13",
            "month": "12",
            "month_wilz": "12",
            "month_abbr": "Dec",
            "month_full": "December",
            "month_days": "31",
            "day": "5",
            "day_wilz": "05",
            "day_abbr": "Mon",
            "day_full": "Monday",
            "year": "2018",
            "year_abbr": "16",
            "hour_12_wolz": "1",
            "hour_12_wilz": "01",
            "hour_24_wolz": "1",
            "hour_24_wilz": "01",
            "hour_am_pm": "am",
            "minutes": "35",
            "seconds": "13",
            "week": "49",
            "offset_seconds": "-28800",
            "offset_minutes": "-480",
            "offset_hours": "-8",
            "offset_gmt": "-08:00",
            "offset_tzid": "America\/Los_Angeles",
            "offset_tzab": "PST",
            "offset_tzfull": "Pacific Standard Time",
            "tz_string": "PST8PDT,M3.3.0/2,M11.2.0/2",
            "dst": "false",
            "dst_observes": "true",
            "timeday_spe": "late_night",
            "timeday_gen": "night"
        }
    }
}

Testing 1, 2, 3.. Sign up when you're ready!

We've made it easy for you to test out our API's. Simply click the "Token" link on each API page and a temporary token is generated instantly. You can generate up to five test tokens. Each token is valid for 20 requests. When you're ready to put the code into production then sign up for a plan to get a service token.

Service Token  (for testing)

A test token has been generated for you. It's good for 20 requests. Please notice: When using a test token the request reponse time is reduced drastically.

TOKEN Copied note_add