The timezone API enables you to request a time zone and get the details about the time zone in return.
Data
Please URL encode all parameter values.
Returns timezone and datetime information. Date/time defaults to when the request was made.
$ curl https://timezoneapi.io/api/timezone/?Europe/Paris&token=TOKEN
// Get JSON object
$jsondata = file_get_contents("https://timezoneapi.io/api/timezone/?Europe/Paris&token=TOKEN");
// Decode
$data = json_decode($jsondata, true);
// Request OK?
if($data['meta']['code'] == '200'){
// Example: Get location
echo "Location: " . $data['data']['timezone']['location'] . "<br>";
// Example: Get the users time
echo "Time: " . $data['data']['timezone']['datetime']['date_time_txt'] . "<br>";
}
// Require
const request = require('request');
// Request
request('https://timezoneapi.io/api/timezone/?Europe/Paris&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 location
var location = data.data.timezone.location;
// Example: Get the users time
var time = data.data.timezone.datetime.date_time_txt;
}
});
// Get JSON object
$.getJSON('https://timezoneapi.io/api/timezone/?Europe/Paris&token=TOKEN', function(data){
// Request OK?
if(data.meta.code == '200'){
// Log
console.log(data);
// Example: Get location
var location = data.data.timezone.location;
alert(location);
// 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/timezone/?Europe/Paris&token=TOKEN').read)
# If OK, get values
if data['meta']['code'] = 200
location = data['data']['timezone']['location']
puts location
time = data['data']['timezone']['datetime']['date_time_txt']
puts time
end
# Import
import requests
# Get
response = requests.get('https://timezoneapi.io/api/timezone/?Europe/Paris&token=TOKEN')
# Parse JSON
data = response.json()
# If ok, get values
if data['meta']['code'] = 200:
Location = data['data']['timezone']['location']
print Location
Time = data['data']['datetime']['date_time_txt']
print Time
Returns
{ "meta": { "code": "200" }, "data": { "timezone": { "id": "Europe\/Paris", "location": "48.86666,2.33333", "country_code": "FR", "country_name": "France", "iso3166_1_alpha_2": "FR", "iso3166_1_alpha_3": "FRA", "un_m49_code": "250", "itu": "F", "marc": "fr", "wmo": "FR", "ds": "F", "phone_prefix": "33", "fifa": "FRA", "fips": "FR", "gual": "85", "ioc": "FRA", "currency_alpha_code": "EUR", "currency_country_name": "FRANCE", "currency_minor_unit": "2", "currency_name": "Euro", "currency_code": "978", "independent": "Yes", "capital": "Paris", "continent": "EU", "tld": ".fr", "languages": "fr-FR,frp,br,co,ca,eu,oc", "geoname_id": "3017382", "edgar": "I0" }, "datetime": { "date": "12\/11\/2024", "date_time": "12\/11\/2024 21:52:57", "date_time_txt": "Sunday, December 11, 2024 21:52:57", "date_time_wti": "Sun, 11 Dec 2024 21:52:57 +0100", "date_time_ymd": "2024-12-11T21:52:57+01:00", "time": "21:52:57", "month": "12", "month_wilz": "12", "month_abbr": "Dec", "month_full": "December", "month_days": "31", "day": "11", "day_wilz": "11", "day_abbr": "Sun", "day_full": "Sunday", "year": "2024", "year_abbr": "16", "hour_12_wolz": "9", "hour_12_wilz": "09", "hour_24_wolz": "21", "hour_24_wilz": "21", "hour_am_pm": "pm", "minutes": "52", "seconds": "57", "week": "49", "offset_seconds": "3600", "offset_minutes": "60", "offset_hours": "1", "offset_gmt": "+01:00", "offset_tzid": "Europe\/Paris", "offset_tzab": "CET", "offset_tzfull": "Central European Time", "tz_string": "CET-1CEST,M3.5.0/2,M10.5.0/3", "dst": "false", "dst_observes": "true", "timeday_spe": "evening", "timeday_gen": "evening" } } }
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.