Timezone Lookup API - Get Timezone from IP and More

The Timezone Lookup API allows you to retrieve timezone from IP address, location address, coordinates, or timezone name. This API delivers a wide range of date and time information, including the current time, date in multiple formats, week, month, year, and Unix timestamp.

Get the time zone information by following ways:

  1. From time zone name
  2. From address (preferably city and country)
  3. From location coordinates (latitude and longtitude)
  4. From IP address

When requesting information using an IP address with the time zone API, the response will also include "geo" field for geolocation information. In this scenario, you can also specify an additional "lang" parameter to receive geolocation information in multiple languages.

10K Free Credits, No Credit Card Required

Features

Real-Time Data

Get up-to-the-second timezone offset between two locations. Users always receive the most current and accurate time details.

Diverse Input Options

Use timezone name, location address, or location coordinates to perform time conversion making the api suitable for a wide range of applications.

Documentation

API Endpoint

GET

https://api.apifreaks.com/v1.0/geolocation/timezone

Test
LANGUAGE
Python
PHP
Java
Node
Ruby
$ pip install requests

API Request

ParameterRequiredTypeDefaultDescription
ipNoStringrequest ip
IPv4 or IPv6 address to extract time zone informatin using IP address
tzNoString
Extract time zone information using timezone name
locationNoString
Extract time zone information using location (preferably city and country)
latNoNumber
Latitude to extract time zone informatin using location coordinates
longNoNumber
Longitude to extract time zone informatin using location coordinates
langNoStringen
response language of "geo" field in case of lookup through IP address / location address. Possible values are: (1) en (English) (2) de (German) (3) ru (Russian) (4) ja (Japanese) (5) fr (French) (6) cn (Chinese Simplifed) (7) es (Spanish) (8) cs (Czech) (9) it (Italian)

API Response

Below are the response fields when performing a lookup using geographical coordinates or a time-zone name:

FieldTypeRequirementDescription
timezoneStringMandatory
The name of the time zone, e.g., "America/New_York"
timezone_offsetNumberMandatory
The time difference in hours from UTC for the specified time zone without considering DST
timezoneoffsetwith_dstNumberMandatory
The time difference in hours from UTC for the specified time zone, including DST
dateStringMandatory
The current date in the specified time zone in YYYY-MM-DD format
date_timeStringMandatory
The current date and time in the specified time zone in ISO 8601 format
datetimetxtStringMandatory
The current date and time in a human-readable format, e.g., "Wednesday, July 26, 2024, 15:00:00"
datetimewtiStringMandatory
The current date and time in the specified time zone in "Weekday, Time" format
datetimeymdStringMandatory
The current date and time in "YYYY-MM-DD HH:MM:SS" format
datetimeunixFloatMandatory
The current date and time as a Unix timestamp (seconds since Jan 1, 1970)
time_24StringMandatory
The current time in 24-hour format, e.g., "15:00:00"
time_12StringMandatory
The current time in 12-hour format with AM/PM, e.g., "03:00:00 PM"
weekNumberMandatory
The current week number of the year in the specified time zone
monthNumberMandatory
The current month number in the specified time zone
yearNumberMandatory
The current year in the specified time zone
year_abbrStringMandatory
The abbreviated current year in the specified time zone, e.g., "24" for 2024
is_dstBooleanMandatory
Indicates whether Daylight Saving Time (DST) is currently in effect in the specified time zone
dst_savingsNumberMandatory
The amount of time (in hours) by which clocks are adjusted for DST
dst_existsBooleanMandatory
Indicates whether DST is observed in the specified time zone
dst_startStringOptional
The start date of the DST period in the specified time zone
dst_endStringOptional
The end date of the DST period in the specified time zone
dststart.utctimeStringMandatory
The UTC time of the DST start date
dst_start.durationStringMandatory
The duration of the DST start transition
dst_start.gapBooleanMandatory
Indicates whether there is a time gap at the start of DST
dst_start.datetimeAfterStringMandatory
The date and time after the start of DST
dst_start.datetimeBeforeStringMandatory
The date and time before the start of DST
dst_start.overlapBooleanMandatory
Indicates whether there is an overlap period at the start of DST
dstend.utctimeStringMandatory
The UTC time of the DST end date
dst_end.durationStringMandatory
The duration of the DST end transition
dst_end.gapBooleanMandatory
Indicates whether there is a time gap at the end of DST
dst_end.datetimeAfterStringMandatory
The date and time after the end of DST
dst_end.datetimeBeforeStringMandatory
The date and time before the end of DST
dst_end.overlapBooleanMandatory
Indicates whether there is an overlap period at the end of DST

The following fields will be appended to the above response based on the lookup performed using a location address:

FieldTypeRequirementDescription
geo.locationStringMandatory
The complete geographical location, including country, state, city, and locality
geo.countryStringOptional
The country of the geographical location
geo.stateStringOptional
The state of the geographical location
geo.cityStringOptional
The city of the geographical location
geo.localityStringOptional
The locality or neighborhood of the geographical location
geo.latitudeFloatMandatory
The latitude coordinate of the geographical location
geo.longitudeFloatMandatory
The longitude coordinate of the geographical location

The following fields will be appended to the above response based on the lookup performed using an IP address:

FieldTypeRequirementDescription
geo.country_code2StringMandatory
The 2-letter country code (ISO 3166-1 alpha-2)
geo.country_code3StringMandatory
The 3-letter country code (ISO 3166-1 alpha-3)
geo.country_nameStringMandatory
The common name of the country
geo.country_name_officialStringMandatory
The official name of the country
geo.state_provStringOptional
The state or province of the geographical location
geo.state_codeStringOptional
The code for the state or province
geo.districtStringOptional
The district of the geographical location
geo.cityStringOptional
The city of the geographical location
geo.zip_codeStringOptional
The postal code of the geographical location
geo.latitudeStringOptional
The latitude coordinate of the geographical location
geo.longitudeStringOptional
The longitude coordinate of the geographical location

HTTP Error Codes

HTTP StatusReasons
400
(1) When provided Latitude and Longitude values are not valid (2) When provided timezone is not valid (3) When time zone detail couldn't be found for the provided IP address

How-To-Guides

Timezone Information for an Address

Pass the address using location query parameter to get the timezone information for an address.

$ curl --location --request GET ' https://api.apifreaks.com/v1.0/geolocation/timezone?apiKey=API-KEY&location=London,%20UK'
# Response { "geo": { "country": "United Kingdom", "state": "England", "city": "London", "latitude": 51.505182, "longitude": -0.0999387 }, "timezone": "Europe/London", "timezone_offset": 0, "date": "2020-12-21", "date_time": "2020-12-21 13:17:59", "date_time_txt": "Monday, December 21, 2020 13:17:59", "date_time_wti": "Mon, 21 Dec 2020 13:17:59 +0000", "date_time_ymd": "2020-12-21T13:17:59+0000", "date_time_unix": 1608556679.524, "time_24": "13:17:59", "time_12": "01:17:59 PM", "week": "52", "month": "12", "year": "2020", "year_abbr": "20", "is_dst": false, "dst_savings": 1 }

When getting timezone information using the location address, the response will also contain the geo field for location information.

Timezone Information for Location Coordinates

Pass the latitude and longitude of a location as query parameters lat and long to get the timezone information for provided coordinates.

$ curl 'https://api.apifreaks.com/v1.0/geolocation/timezone?apiKey=API-KEY&lat=-27.4748&long=153.017'
# Response { "timezone": "Australia/Brisbane", "timezone_offset": 10, "date": "2020-12-21", "date_time": "2020-12-21 23:49:16", "date_time_txt": "Monday, December 21, 2020 23:49:16", "date_time_wti": "Mon, 21 Dec 2020 23:49:16 +1000", "date_time_ymd": "2020-12-21T23:49:16+1000", "date_time_unix": 1608558556.584, "time_24": "23:49:16", "time_12": "11:49:16 PM", "week": "52", "month": "12", "year": "2020", "year_abbr": "20", "is_dst": false, "dst_savings": 0 }

IP to Timezone API

Get timezone from IPv4 or IPv6 address by passing the ip query parameter to the IP to timezone API. The response will include both timezone and geolocation details. If the ip is not provided, the API will default to using the request's IP address.

$ curl 'https://api.apifreaks.com/v1.0/geolocation/timezone?apiKey=API-KEY&ip=1.1.1.1'
# Response { "geo": { "ip": "1.1.1.1", "country_code2": "AU", "country_code3": "AUS", "country_name": "Australia", "state_prov": "Queensland", "district": "South Brisbane", "city": "Brisbane", "zipcode": "4101", "latitude": "-27.47561", "longitude": "153.01537" }, "timezone": "Australia/Brisbane", "timezone_offset": 10, "date": "2020-12-21", "date_time": "2020-12-21 23:49:42", "date_time_txt": "Monday, December 21, 2020 23:49:42", "date_time_wti": "Mon, 21 Dec 2020 23:49:42 +1000", "date_time_ymd": "2020-12-21T23:49:42+1000", "date_time_unix": 1608558582.413, "time_24": "23:49:42", "time_12": "11:49:42 PM", "week": "52", "month": "12", "year": "2020", "year_abbr": "20", "is_dst": false, "dst_savings": 0 }

When getting timezone information using the ip address, the response will also contain the geo field for geolocation information for the ip address location. To get the geolocation information in a specific language, provide the language code using the lang parameter. Default geolocation response is in English.

$ curl 'https://api.apifreaks.com/v1.0/geolocation/timezone?apiKey=API-KEY&ip=1.1.1.1&lang=es
The languages supported are:
  • en (English)
  • es(Spanish)
  • de (German)
  • fr (French)
  • ja (Japanese)
  • it (Italian)
  • cs (Czech)
  • ru (Russian)
  • cn (Chinese Simplifed)

Timezone Information for Calling Machine IP

Call the API without passing any location, coordinates, or IP address. It will use the calling machine's IP address to return the ip timezone information.

$ curl 'https://api.apifreaks.com/v1.0/geolocation/timezone?apiKey=API-KEY'

Pricing

To use the TimeZone API, API credits are required. Charges apply only for successful queries, defined by a 2xx status code. If a request results in a 4xx or 5xx status code, no credits will be deducted, and any credits already charged will be refunded.

For each successful request, 1 credit will be charged for time zone lookup. Utilize the Credits Usage API to efficiently monitor your recent consumption of both one-off and subscription credits. This API provides a streamlined way to track and manage your credit usage, ensuring you stay informed about your remaining balance and can optimize your resource allocation effectively.

Price Estimation Calculator