How to Use Timezone API

- Travel & Logistics: Know the local time for shipping or flights.
- E-commerce: Display product launch times in local time zones.
- Remote Teams: Coordinate meetings across different geographical locations.
- Finance: Monitor currency based on the timezone.
Pre-Requisites
To access the EasyAPI Timezone Endpoint, you will need an API key. If you don’t have an API key yet, please refer to the Getting Started Guide to learn how to obtain one.
Step 1: Make an API Request
In Browser
You can directly access the API via your web browser by navigating to the following URL, replacing YOUR_API_KEY
with your actual API key:
https://api.easyapi.io/v1.0/timezone?timezone=Europe/Berlin&api_key=YOUR_API_KEY
In Python
You can use Python’s requests
library to make the API call. Here’s a sample code snippet:
import requests
url = "https://api.easyapi.io/v1.0/timezone"
params = {
'timezone': 'Europe/Berlin',
'api_key': 'YOUR_API_KEY'
}
response = requests.get(url, params=params)
data = response.json()
In PHP
You can use PHP’s cURL
to fetch the data:
"https://api.easyapi.io/v1.0/timezone?timezone=Europe/Berlin&api_key=YOUR_API_KEY",
CURLOPT_RETURNTRANSFER => true
));
$response = curl_exec($curl);
$data = json_decode($response, true);
curl_close($curl);
?>
Step 2: Analyze the Response
After making the API call, you’ll receive a JSON response similar to the one presented below:
{
"class":"timezone_info",
"properties":{
"datetime":{
"date":"08/23/2023",
"date_time":"08/23/2023 21:50:09",
"date_time_txt":"Wednesday, August 23, 2023 21:50:09",
"date_time_wti":"Wed, 23 Aug 2023 21:50:09 +0200",
"date_time_ymd":"2023-08-23T21:50:09+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":"50",
"month":"08",
"month_abbr":"Aug",
"month_days":"23",
"month_full":"August",
"month_wilz":"08",
"seconds":"09",
"time":"21:50:09",
"week":"34",
"year":"2023",
"year_abbr":"23"
},
"timezone":{
"capital":"Berlin",
"continent":"EU",
"country":"Germany",
"country_code":"DE",
"currency_alpha_code":"EUR",
"currency_code":"978",
"currency_country_minor_unit":"2",
"currency_country_name":"GERMANY",
"currency_name":"Euro",
"ds":"D",
"edgar":"2M",
"fifa":"GER",
"fips":"GM",
"gaul":"93",
"geoname_id":"2921044",
"id":"Europe/Berlin",
"independent":true,
"ioc":"GER",
"iso3166_1_alpha_2":"DE",
"iso3166_1_alpha_3":"DEU",
"itu":"D",
"languages":"de",
"location":"52.5, 13.366666666666667",
"marc":"gw",
"phone_prefix":"49",
"tld":".de",
"un_m49_code":"276",
"wmo":"DL"
}
}
}
Field Descriptions
Datetime Fields
Field Name | Description | Example Value |
---|---|---|
date | The date | “08/23/2023” |
date_time | Complete date and time | “08/23/2023 21:50:09” |
date_time_txt | Date and time in text format | “Wednesday, August 23, 2023 21:50:09” |
date_time_wti | Date and time with timezone info | “Wed, 23 Aug 2023 21:50:09 +0200” |
date_time_ymd | ISO-8601 formatted date and time | “2023-08-23T21:50:09+0200” |
day | Day of the month | “23” |
day_abbr | Abbreviated day name | “Wed” |
day_full | Full day name | “Wednesday” |
day_wilz | Day of the month with leading zero | “23” |
hour_12_wilz | 12-hour format of the hour with leading zero | “09” |
hour_12_wolz | 12-hour format of the hour without leading zero | “9” |
hour_24_wilz | 24-hour format of the hour with leading zero | “21” |
hour_24_wolz | 24-hour format of the hour without leading zero | “21” |
hour_am_pm | AM or PM | “pm” |
minutes | Minutes | “50” |
month | Month | “08” |
month_abbr | Abbreviated month name | “Aug” |
month_days | Day of the month | “23” |
month_full | Full month name | “August” |
month_wilz | Month with leading zero | “08” |
seconds | Seconds | “09” |
time | Time in HH:MM:SS format | “21:50:09” |
week | Week of the year | “34” |
year | Year | “2023” |
year_abbr | Abbreviated year | “23” |
Timezone Fields
Field Name | Description | Example Value |
---|---|---|
capital | Capital of the region | “Berlin” |
continent | Continent code | “EU” |
country | Country name | “Germany” |
country_code | Country ISO code | “DE” |
currency_alpha_code | Currency Alpha code | “EUR” |
currency_code | Currency ISO code | “978” |
currency_country_minor_unit | Currency minor unit | “2” |
currency_country_name | Country name for currency | “GERMANY” |
currency_name | Currency name | “Euro” |
ds | Daylight Saving code | “D” |
edgar | Edgar code | “2M” |
fifa | FIFA code | “GER” |
fips | FIPS code | “GM” |
gaul | GAUL code | “93” |
geoname_id | Geoname ID | “2921044” |
id | Timezone ID | “Europe/Berlin” |
independent | Country’s independence status | true |
ioc | IOC code | “GER” |
iso3166_1_alpha_2 | ISO 3166-1 alpha-2 code | “DE” |
iso3166_1_alpha_3 | ISO 3166-1 alpha-3 code | “DEU” |
itu | ITU code | “D” |
languages | Spoken languages | “de” |
location | Geographical coordinates (latitude, longitude) | “52.5, 13.366666666666667” |
marc | MARC code | “gw” |
phone_prefix | Phone prefix | “49” |
tld | Top Level Domain | “.de” |
un_m49_code | UN M49 code | “276” |
wmo | WMO code | “DL” |
Step 3: Implement in Your Application
Now that you have successfully fetched and analyzed the time and geographical information, you can use this data in a myriad of ways in your application:
- Show Local Time: Use the
datetime
object to display local time to your users. - Currency Conversion: Leverage the
currency_code
to convert prices to the local currency in real-time. - Localization: Use the
languages
andcountry
fields to tailor your application’s language to the user.
Here’s an example message you can display to greet your users based on their local time:
Python implementation
# Python Example
if int(data['properties']['datetime']['hour_24_wilz']) < 12:
greeting = "Good Morning!"
elif int(data['properties']['datetime']['hour_24_wilz']) < 18:
greeting = "Good Afternoon!"
else:
greeting = "Good Evening!"
print(f"{greeting} Welcome to our service!")
PHP implementation
Conclusion
Congratulations! You’ve successfully learned how to use EasyAPI’s Timezone Endpoint to retrieve and implement local time data in your application. The flexibility of this endpoint can be immensely useful for various business use-cases, from personalizing greetings to conducting location-based analytics.
What's Next?
Getting Started: If you’re new to EasyAPI or need a refresher on how to get started, be sure to check out our Getting Started Guide.
More Endpoints: Interested in more functionalities? Take a look at our guide for the IP Address Lookup Endpoint, which is similar to this one but tailored for obtaining IP address information.
For Developers: For a deep dive into all available endpoints, parameters, and functionalities, visit our comprehensive API documentation in redoc.
Your journey with EasyAPI is just getting started. We have a range of features and endpoints to meet your needs, and our documentation is always here to help you find your way. Feel free to reach out with any questions or suggestions; we’re always keen to hear your feedback.
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