How to Use Timezone Comparison API

The EasyAPI Compare Endpoint is a robust feature that allows you to effortlessly compare various location-based attributes such as IP addresses, physical addresses, and time zones. This functionality is especially useful in a multitude of business scenarios, from personalizing user experiences based on local time zones to implementing geo-based access controls for your digital resources.
Pre-Requisites
Before you can access the Compare Endpoint, you’ll need to obtain an API key from EasyAPI. If you haven’t done this yet, you can find the steps to get your API key in the Getting Started Guide.
Step 1: Make an API Request
In Browser
You can make a simple API request by entering the following URL into your web browser:
https://api.easyapi.io/v1.0/compare?ip1=82.84.2.2&timezone2=Europe/Helsinki&api_key=YOUR_API_KEY
In Python
You can use the Python requests library to make an API call as follows:
import requests
api_key = "YOUR_API_KEY"
url = "https://api.easyapi.io/v1.0/compare"
params = {
"ip1": "82.84.2.2",
"timezone2": "Europe/Helsinki",
"api_key": api_key
}
response = requests.get(url, params=params)
data = response.json()
In PHP
In PHP, you can use the curl extension to make the API request:
Step 2: Analyze the Response
Response Body
Here’s a snippet of the response body you’d get:
{
"class":"compare",
"properties":{
"address1":null,
"address2":null,
"compare":{
"time_difference_hours":1,
"time_difference_minutes":60,
"time_difference_seconds":3600,
"distance_feet":6164939,
"distance_km":1879,
"distance_meters":1879074,
"distance_miles":1168,
"distance_nautical_miles":1015,
},
"ip1":{
"city":"Pescantina",
"country":"Italy",
"country_code":"IT",
"datetime":{
"date":"08/23/2023",
"date_time":"08/23/2023 21:56:35",
"date_time_txt":"Wednesday, August 23, 2023 21:56:35",
"date_time_wti":"Wed, 23 Aug 2023 21:56:35 +0200",
"date_time_ymd":"2023-08-23T21:56:35+0200",
"day":"23",
"day_abbr":"Wed",
"day_full":"Wednesday",
"day_wilz":"23",
"hour_12_wilz":"09",
"hour_12_wolz":"9",
"hour_24_wilz":"21",
"hour_24_wolz":"21",
"hour_am_pm":"pm",
"minutes":"56",
"month":"08",
"month_abbr":"Aug",
"month_days":"23",
"month_full":"August",
"month_wilz":"08",
"seconds":"35",
"time":"21:56:35",
"week":"34",
"year":"2023",
"year_abbr":"23"
},
"ip":"82.84.2.2",
"location":"45.4802,10.867",
"postal":"37026",
"state":"Province of Verona",
"state_code":"VR",
"timezone":{
"capital":"Rome",
"continent":"EU",
"country":"Italy",
"country_code":"IT",
"currency_alpha_code":"EUR",
"currency_code":"978",
"currency_country_minor_unit":"2",
"currency_country_name":"ITALY",
"currency_name":"Euro",
"ds":"I",
"edgar":"L6",
"fifa":"ITA",
"fips":"IT",
"gaul":"122",
"geoname_id":"3175395",
"id":"Europe/Rome",
"independent":true,
"ioc":"ITA",
"iso3166_1_alpha_2":"IT",
"iso3166_1_alpha_3":"ITA",
"itu":"I",
"languages":"it-IT,de-IT,fr-IT,sc,ca,co,sl",
"location":"41.9, 12.483333333333333",
"marc":"it",
"phone_prefix":"39",
"tld":".it",
"un_m49_code":"380",
"wmo":"IY"
}
},
"ip2":null,
"timezone1":null,
"timezone2":{
"datetime":{
"date":"08/23/2023",
"date_time":"08/23/2023 22:56:36",
"date_time_txt":"Wednesday, August 23, 2023 22:56:36",
"date_time_wti":"Wed, 23 Aug 2023 22:56:36 +0300",
"date_time_ymd":"2023-08-23T22:56:36+0300",
"day":"23",
"day_abbr":"Wed",
"day_full":"Wednesday",
"day_wilz":"23",
"hour_12_wilz":"10",
"hour_12_wolz":"10",
"hour_24_wilz":"22",
"hour_24_wolz":"22",
"hour_am_pm":"pm",
"minutes":"56",
"month":"08",
"month_abbr":"Aug",
"month_days":"23",
"month_full":"August",
"month_wilz":"08",
"seconds":"36",
"time":"22:56:36",
"week":"34",
"year":"2023",
"year_abbr":"23"
},
"timezone":{
"capital":"Helsinki",
"continent":"EU",
"country":"Finland",
"country_code":"FI",
"currency_alpha_code":"EUR",
"currency_code":"978",
"currency_country_minor_unit":"2",
"currency_country_name":"FINLAND",
"currency_name":"Euro",
"ds":"FIN",
"edgar":"H9",
"fifa":"FIN",
"fips":"FI",
"gaul":"84",
"geoname_id":"660013",
"id":"Europe/Helsinki",
"independent":true,
"ioc":"FIN",
"iso3166_1_alpha_2":"FI",
"iso3166_1_alpha_3":"FIN",
"itu":"FIN",
"languages":"fi-FI,sv-FI,smn",
"location":"60.166666666666664, 24.966666666666665",
"marc":"fi",
"phone_prefix":"358",
"tld":".fi",
"un_m49_code":"246",
"wmo":"FI"
}
}
}
}
Fields Description
Field Name | Description | Example Value |
---|---|---|
class |
The class type of the response | “compare” |
properties.address1 |
First address for comparison (if applicable) | null |
properties.address2 |
Second address for comparison (if applicable) | null |
properties.compare.time_difference_hours |
Time difference between locations in hours | 1 |
properties.compare.time_difference_minutes |
Time difference between locations in minutes | 60 |
properties.compare.time_difference_seconds |
Time difference between locations in seconds | 3600 |
properties.compare.distance_feet |
Distance between locations in feet | 6164939 |
properties.compare.distance_km |
Distance between locations in kilometers | 1879 |
properties.compare.distance_meters |
Distance between locations in meters | 1879074 |
properties.compare.distance_miles |
Distance between locations in miles | 1168 |
properties.compare.distance_nautical_miles |
Distance between locations in nautical miles | 1015 |
properties.ip1.city |
City of the first IP address | “Pescantina” |
properties.ip1.country |
Country of the first IP address | “Italy” |
properties.ip1.country_code |
Country code of the first IP address | “IT” |
properties.ip1.datetime.date |
Date for the first IP address | “08/23/2023” |
properties.ip1.datetime.time |
Time for the first IP address | “21:56:35” |
properties.ip1.ip |
IP address of the first location | “82.84.2.2” |
properties.ip1.location |
Geographical coordinates of the first IP address | “45.4802,10.867” |
properties.ip1.postal |
Postal code of the first IP address | “37026” |
properties.ip1.state |
State or province of the first IP address | “Province of Verona” |
properties.ip1.state_code |
State code of the first IP address | “VR” |
properties.ip1.timezone.capital |
Capital city of the timezone for the first IP | “Rome” |
properties.ip1.timezone.continent |
Continent of the timezone for the first IP | “EU” |
properties.ip1.timezone.currency_name |
Currency name used in the first IP’s country | “Euro” |
properties.ip1.timezone.languages |
Languages spoken in the first IP’s timezone | “it-IT,de-IT,fr-IT,sc,ca,co,sl” |
properties.ip1.timezone.phone_prefix |
Phone prefix for the first IP’s country | “39” |
properties.ip1.timezone.tld |
Top-level domain for the first IP’s country | “.it” |
properties.ip2 |
Information about the second IP address (if applicable) | null |
properties.timezone1 |
Timezone information for the first entity (if applicable) | null |
properties.timezone2.datetime.date |
The date for the second timezone | “08/23/2023” |
properties.timezone2.datetime.time |
The time for the second timezone | “22:56:36” |
properties.timezone2.timezone.capital |
Capital city of the second timezone | “Helsinki” |
properties.timezone2.timezone.continent |
Continent of the second timezone | “EU” |
properties.timezone2.timezone.currency_name |
Currency name used in the second timezone | “Euro” |
properties.timezone2.timezone.languages |
Languages spoken in the second timezone | “fi-FI,sv-FI,smn” |
properties.timezone2.timezone.phone_prefix |
Phone prefix for the second timezone’s country | “358” |
properties.timezone2.timezone.tld |
Top-level domain for the second timezone’s country | “.fi” |
Step 3: Implement in Your Application
Once you have the comparison data, you can integrate it into your application for various purposes:
- Personalization: Customize your application’s UI based on the user’s local time.
- Access Control: Restrict or grant access to resources based on geographic location.
- Route planning: Create optimised routes, based on distances between locations
Conclusion
Congratulations! You have successfully implemented the Compare Endpoint into your application.
The Compare Endpoint is a versatile tool that enables a multitude of use-cases and functionalities, enriching both your data insights and user experience.
What's Next?
For more information and functionalities, explore the following:
- Getting Started Guide
- IP Address Lookup Guide
- Timezone API Guide
- Address Geolocation Guide
- API Docs for Developers
Happy coding!
Choose the Plan That Fits Your Need
Easy, transparent, and budget-friendly!
Free
$0
- 5.000 API calls
- Time zones
- Time zone comparison
- IP Address
- Address info
- Fast support
- Nearby places by IP
- Frequent database updates
- Multiple sources
- Commercial use
Commercial
$37/mo
- 500.000 API calls per month
- Time zones
- Time zone comparison
- IP Address
- Address info
- Fast support
- Nearby places by IP
- Frequent database updates
- Multiple sources
- Commercial use
Premium
$59/mo
- 2 million API calls per month
- Time zones
- Time zone comparison
- IP Address
- Address info
- Fast support
- Nearby places by IP
- Frequent database updates
- Multiple sources
- Commercial use
Business
$139/mo
- 6 million API calls per month
- Time zones
- Time zone comparison
- IP Address
- Address info
- Fast support
- Nearby places by IP
- Frequent database updates
- Multiple sources
- Commercial use