Time Zone API and IP to Timezone Lookup

ipgeolocation's free Timezone API provides time and date related information such as current time, date in various formats, week, month, year, time in unix timestamp, UTC/GMT offset and day light saving time from timezone name, any IPv4 or IPv6 address or geolocation coordinates in REST, JSON and XML format over secure HTTPS connection.

  • objectGeo:Object,
    • fieldcountry_code2:"",
    • fieldcountry_code3:"",
    • fieldcountry_name:"",
    • fieldcountry_name:"",
    • fieldstate_prov:"",
    • fielddistrict:"",
    • fieldcity:"",
    • fieldzipcode:"",
    • fieldlatitude:"",
    • fieldlongitude:""
  • fieldtimezone:"",
  • fieldtimezone_offset:"",
  • fieldtimezone_offset_with_dst:"",
  • fielddate:"",
  • fielddate_time:"",
  • fielddate_time_txt:"",
  • fielddate_time_wti:"",
  • fielddate_time_ymd:"",
  • fielddate_time_unix:"",
  • fieldtime_24:"",
  • fieldtime_12:"",
  • fieldweek:"",
  • fieldmonth:"",
  • fieldyear:"",
  • fieldyear_abbr:"",
  • fieldis_dst:"",
  • fielddst_savings:""

Detailed Timezone Data

Detailed timezone data consists of current time, date in various date formats, day light saving information and geolocation data(in case of ip to timezone call).

Response

1{
2    timezone: "America/Los_Angeles",
3    timezone_offset: "-8",
4    date: "2019-05-08",
5    date_time: "2019-05-08 03:16:34",
6    date_time_txt: "Wednesday, May 08, 2019 03:16:34",
7    date_time_wti: "Wed, 08 May 2019 03:16:34 -0700",
8    date_time_ymd: "2019-05-08T03:16:34-0700",
9    date_time_unix: "1557310594.381",
10    time_24: "03:16:34",
11    time_12: "03:16:34 AM",
12    week: "19",
13    month: "05",
14    year: "2019",
15    year_abbr: "19",
16    is_dst: true,
17    dst_savings: "1",
18  }

Getting Time Zone Information from a Timezone name

You can pass a valid time zone name as a query parameter tz to get the time zone information. Here is a curl example:

Response

1{
2    timezone: "America/Los_Angeles",
3    timezone_offset: "-8",
4    date: "2019-05-08",
5    date_time: "2019-05-08 03:16:34",
6    date_time_txt: "Wednesday, May 08, 2019 03:16:34",
7    date_time_wti: "Wed, 08 May 2019 03:16:34 -0700",
8    date_time_ymd: "2019-05-08T03:16:34-0700",
9    date_time_unix: "1557310594.381",
10    time_24: "03:16:34",
11    time_12: "03:16:34 AM",
12    week: "19",
13    month: "05",
14    year: "2019",
15    year_abbr: "19",
16    is_dst: true,
17    dst_savings: "1",
18  }

Getting Timezone Information from a Location Coordinates

You can pass the latitude and longitude of a location as query parameters to get the timezone information. Here is a curl example:

Response

1{
2    timezone: "Australia/Brisbane",
3    timezone_offset: "10",
4    date: "2019-05-09",
5    date_time: "2019-05-09 16:19:51",
6    date_time_txt: "Thursday, May 09, 2019 16:19:51",
7    date_time_wti: "Thu, 09 May 2019 16:19:51 +1000",
8    date_time_ymd: "2019-05-09T16:19:51+1000",
9    date_time_unix: "1557382791.6194",
10    time_24: "16:19:51",
11    time_12: "04:19:51 PM",
12    week: "19",
13    month: "05",
14    year: "2019",
15    year_abbr: "19",
16    is_dst: false,
17    dst_savings: "0",
18  }

Getting Timezone Information from an IPv4 or IPv6 Address

You can pass any IPv4 or IPv6 address as a query parameter to get the regional time zone information. Here is a curl example:

Response

1{
2    geo: {
3      ip: "Asia/Karachi",
4      country_code2: "US",
5      country_code3: "USA",
6      country_name: "United States",
7      state_prov: "California",
8      district: "Santa Clara County",
9      city: "Mountain View",
10      zipcode: "94041",
11      latitude: "37.42290",
12      longitude: "-122.08500",
13    },
14    timezone: "America/Los_Angeles",
15    timezone_offset: "-8",
16    date: "2019-05-09",
17    date_time: "2019-05-09 01:05:31",
18    date_time_txt: "Thursday, May 09, 2019 01:05:31",
19    date_time_wti: "Thu, 09 May 2019 01:05:31 -0700",
20    date_time_ymd: "2019-05-09T01:05:31-0700",
21    date_time_unix: "1557389131.428",
22    time_24: "01:05:31",
23    time_12: "01:05:31 AM",
24    week: "19",
25    month: "05",
26    year: "2019",
27    year_abbr: "19",
28    is_dst: true,
29    dst_savings: "1",
30  }

Response in Multiple Languages

You can retrieve the geolocation information for an IP address in the following languages:

US FlagEnglish DE FlagGerman RU FlagRussian JP FlagJapanese FR FlagFrench CN FlagChinese Simplified ES FlagSpanish CZ FlagCzech IT FlagItalian

Use Cases

New Timezone During Traveling

Build an application for Travellers who move a lot between different timezones! Use the timezone API to keep them up-to-date and up-to-time always, no matter how many time zones they have skip over.

iplocation

Ecommerce

Make sure you know which part of the world your buyers are coming from and show them the right message at the(ir) right time.

geoip

Global Communication

For teams that work from all over the globe, make communications a piece of cake using our free time zone API.

iplook-up

Ready to get started?Get Started with IP Intelligence API Today

Timezone API

Time zone API provides current time, date, and time zone related information. It can be consumed with the foloowing input variations:

  • For a Time Zone Name
  • For any Address (preferrably, city address)
  • For Location Coordinates (latitude & longitude)
  • For any IP address

In each variation of the time zone API, response remains same. Here are the details to consume each variation of the time zone API.

Time Zone Information from a Time Zone Name

You can pass a valid time zone name as a query parameter tz to get the time zone information. Here is a curl exmaple:

curl 'https://api.ipgeolocation.io/ipgeo?apiKey=API_KEY&ip=1.1.1.1&fields=geo&include=useragent'

Response

1{               
2"timezone": "America/Los_Angeles",
3"timezone_offset": -8,
4"date": "2018-12-06",
5"date_time": "2018-12-06 02:02:09",
6"date_time_txt": "Thursday, December 06, 2018 02:02:09",
7"date_time_wti": "Thu, 06 Dec 2018 02:02:09 -0800",
8"date_time_ymd": "2018-12-06T02:02:09-0800",
9"date_time_unix": 1544090529.989,
10"time_24": "02:02:09",
11"time_12": "02:02:09 AM",
12"week": "49",
13"month": "12",
14"year": "2018",
15"year_abbr": "18",
16"is_dst": false,
17"dst_savings": 1
18}

Time Zone Information from any Address

You can pass any address of a location as the query parameter to get the time zone information. Here is a curl example:

# Get time zone information for the address 'London, UK'
      $ curl --location --request GET 'https://api.ipgeolocation.io/timezone?apiKey=API_KEY&location=London,%20UK'

Response

1{
2"geo": {
3"country": "United Kingdom",
4"state": "England",
5"city": "London",
6"latitude": 51.505182,
7"longitude": -0.0999387
8},
9"timezone": "Europe/London",
10"timezone_offset": 0,
11"date": "2020-12-21",
12"date_time": "2020-12-21 13:17:59",
13"date_time_txt": "Monday, December 21, 2020 13:17:59",
14"date_time_wti": "Mon, 21 Dec 2020 13:17:59 +0000",
15"date_time_ymd": "2020-12-21T13:17:59+0000",
16"date_time_unix": 1608556679.524,
17"time_24": "13:17:59",
18"time_12": "01:17:59 PM",
19"week": "52",
20"month": "12",
21"year": "2020",
22"year_abbr": "20",
23"is_dst": false,
24"dst_savings": 1
25}

Time Zone Information from Location Coordinates

You can pass the latitude and longitude of a location as query parameters to get the time zone information. Here is a curl example:

# Get time zone information for -27.4748, 153.017 coordinates
      $ curl 'https://api.ipgeolocation.io/timezone?apiKey=API_KEY&lat=-27.4748&long=153.017'

Response

1{
2"timezone": "Australia/Brisbane",
3"timezone_offset": 10,
4"date": "2020-12-21",
5"date_time": "2020-12-21 23:49:16",
6"date_time_txt": "Monday, December 21, 2020 23:49:16",
7"date_time_wti": "Mon, 21 Dec 2020 23:49:16 +1000",
8"date_time_ymd": "2020-12-21T23:49:16+1000",
9"date_time_unix": 1608558556.584,
10"time_24": "23:49:16",
11"time_12": "11:49:16 PM",
12"week": "52",
13"month": "12",
14"year": "2020",
15"year_abbr": "20",
16"is_dst": false,
17"dst_savings": 0
18}

IP to Time Zone

You can pass any IPv4 or IPv6 address as a query parameter to get the regional timezone information. Here is a curl example:

# Get time zone information for IP address '1.1.1.1'
      $ curl 'https://api.ipgeolocation.io/timezone?apiKey=API_KEY&ip=1.1.1.1'

Response

1{
2"geo": {
3"ip": "1.1.1.1",
4"country_code2": "AU",
5"country_code3": "AUS",
6"country_name": "Australia",
7"state_prov": "Queensland",
8"district": "South Brisbane",
9"city": "Brisbane",
10"zipcode": "4101",
11"latitude": "-27.47561",
12"longitude": "153.01537"
13},
14"timezone": "Australia/Brisbane",
15"timezone_offset": 10,
16"date": "2020-12-21",
17"date_time": "2020-12-21 23:49:42",
18"date_time_txt": "Monday, December 21, 2020 23:49:42",
19"date_time_wti": "Mon, 21 Dec 2020 23:49:42 +1000",
20"date_time_ymd": "2020-12-21T23:49:42+1000",
21"date_time_unix": 1608558582.413,
22"time_24": "23:49:42",
23"time_12": "11:49:42 PM",
24"week": "52",
25"month": "12",
26"year": "2020",
27"year_abbr": "20",
28"is_dst": false,
29"dst_savings": 0
30}

Note: When you get the time zone information through an IP address, API will also return the 'geo' field along with the time zone information.

Using Client or Machine IP Address

You can call the time zone API without passing any time zone, coordinates or IP address as well. It will use the calling machine's IP address to return the regional time zone information. Here is a curl example:

$ curl 'https://api.ipgeolocation.io/timezone?apiKey=API_KEY'

This variation is widely used on embedded hardware and IoT to get current time after reboot.

Note:In above examples, we used API Key everywhere. Time zone API can be called from client side JavaScript with Request Origin authentication as well on paid plans.

Response in Multiple Languages

The geolocation information in the response from Time zone API when called using an IP address, can be retreived in the following languages:

  • English (en)
  • German (de)
  • Russian (ru)
  • Japanese (ja)
  • French (fr)
  • Chinese Simplified (cn)
  • Spanish (es)
  • Czech (cs)
  • Italian (it)

By default, the API responds in English. You can change the response language by passing the language code as a query parameter lang. Here are a few curl examples:

# Get geolocation for an IPv4 IP Address = 1.1.1.1 in Chinese language
      $ curl 'https://api.ipgeolocation.io/timezone?apiKey=API_KEY&ip=1.1.1.1&lang=cn'

Note: Multi language feature is available only for paid users.

Convert Time between Time Zones

You can convert a provided timestamp from one time zone to another time zone. You can convert the provided timestamp in three ways:

Convert Time using Time Zone Names

# Convert timestamp between time zones using the time zone names
      $ curl --location --request GET 'https://api.ipgeolocation.io/timezone/convert?apiKey=API_KEY&tz_from=America/Argentina/Catamarca&tz_to=Asia/Kabul&time=2020-12-08%2011:00'

Response

1{
2"original_time": "2020-12-08 11:00",
3"converted_time": "2020-12-08 18:30",
4"diff_hour": 7.5,
5"diff_min": 450
6}

Convert Time using Location Coordinates

# Convert timestamp between time zones using coordinates of the locations
      $ curl --location --request GET 'https://api.ipgeolocation.io/timezone/convert?apiKey=API_KEY&lat_from=34.0207305&long_from=-118.6919163&lat_to=53.4736827&long_to=-77.3977062&time=2020-12-08%2006:00' 

Response

1{
2"original_time": "2020-12-08 11:00",
3"converted_time": "2020-12-08 18:30",
4"diff_hour": 7.5,
5"diff_min": 450
6}

Convert Time using Location Addresses

# Convert timestamp between time zones by location addresses
      $ curl --location --request GET 'https://api.ipgeolocation.io/timezone/convert?apiKey=API_KEY&location_from=New%20York,%20USA&location_to=Lahore,%20Pakistan&time=2020-12-08%2006:00'

Response

1{
2"original_time": "2020-12-08 06:00",
3"converted_time": "2020-12-08 16:00",
4"diff_hour": 9,
5"diff_min": 540
6} 

Note: time=2020-12-08%2006:00 parameter takes the input in the following two formats: i) 'yyyy-MM-dd HH:mm', and ii) 'yyyy-MM-dd HH:mm:ss'. This parameter is optional and you can omit it to convert the current time between two coordinates or locations.