Convert Time endpoint
curl --request GET \
--url https://timezone.abstractapi.com/v1/convert_timeimport requests
url = "https://timezone.abstractapi.com/v1/convert_time"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://timezone.abstractapi.com/v1/convert_time', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://timezone.abstractapi.com/v1/convert_time",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://timezone.abstractapi.com/v1/convert_time"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://timezone.abstractapi.com/v1/convert_time")
.asString();require 'uri'
require 'net/http'
url = URI("https://timezone.abstractapi.com/v1/convert_time")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"base_location": {
"datetime": "2020-05-01 07:00:00",
"timezone_name": "PDT",
"timezone_location": "America/Los_Angeles",
"timezone_abbreviation": "Pacific Daylight Time",
"gmt_offset": -7,
"is_dst": true,
"requested_location": "Los Angeles,CA",
"latitude": 34.0536909,
"longitude": -118.242766
},
"target_location": {
"datetime": "2020-05-01 15:00:00",
"timezone_name": "BST",
"timezone_location": "Europe/London",
"timezone_abbreviation": "British Summer Time",
"gmt_offset": 1,
"is_dst": true,
"requested_location": "Oxford,United Kingdom",
"latitude": 51.7520131,
"longitude": -1.2578499
}
}
Convert Time endpoint
The convert_time endpoint makes it easy to convert the time and date of a given location to the time and date of another location. By default it converts the current time, but the conversion can take place in either the past or future with a simple parameter.
GET
/
v1
/
convert_time
Convert Time endpoint
curl --request GET \
--url https://timezone.abstractapi.com/v1/convert_timeimport requests
url = "https://timezone.abstractapi.com/v1/convert_time"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://timezone.abstractapi.com/v1/convert_time', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://timezone.abstractapi.com/v1/convert_time",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://timezone.abstractapi.com/v1/convert_time"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://timezone.abstractapi.com/v1/convert_time")
.asString();require 'uri'
require 'net/http'
url = URI("https://timezone.abstractapi.com/v1/convert_time")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"base_location": {
"datetime": "2020-05-01 07:00:00",
"timezone_name": "PDT",
"timezone_location": "America/Los_Angeles",
"timezone_abbreviation": "Pacific Daylight Time",
"gmt_offset": -7,
"is_dst": true,
"requested_location": "Los Angeles,CA",
"latitude": 34.0536909,
"longitude": -118.242766
},
"target_location": {
"datetime": "2020-05-01 15:00:00",
"timezone_name": "BST",
"timezone_location": "Europe/London",
"timezone_abbreviation": "British Summer Time",
"gmt_offset": 1,
"is_dst": true,
"requested_location": "Oxford,United Kingdom",
"latitude": 51.7520131,
"longitude": -1.2578499
}
}
Getting started
Base URL
https://timezone.abstractapi.com/v1/convert_time
Validation endpoint
https://timezone.abstractapi.com/v1/convert_time
? api_key = YOUR_UNIQUE_API_KEY
& base_location = Los Angeles, CA
& base_datetime = 2020-05-01 07:00:00
& target_location = Oxford, United Kingdom
{
"base_location": {
"datetime": "2020-05-01 07:00:00",
"timezone_name": "PDT",
"timezone_location": "America/Los_Angeles",
"timezone_abbreviation": "Pacific Daylight Time",
"gmt_offset": -7,
"is_dst": true,
"requested_location": "Los Angeles,CA",
"latitude": 34.0536909,
"longitude": -118.242766
},
"target_location": {
"datetime": "2020-05-01 15:00:00",
"timezone_name": "BST",
"timezone_location": "Europe/London",
"timezone_abbreviation": "British Summer Time",
"gmt_offset": 1,
"is_dst": true,
"requested_location": "Oxford,United Kingdom",
"latitude": 51.7520131,
"longitude": -1.2578499
}
}
Request parameters
Your unique API key. Note that each user has unique API keys for each of Abstract’s APIs, so your Time, Date, and Timezone API key will not work for your User Avatar API, for example.
The location you use as a base to convert the datetime for. This parameter accepts the location as a string (e.g., Los Angeles, CA), a longitude and latitude (e.g., -31.4173391,-64.183319) , or an IP address (e.g., 82.111.111.111)
The location you want to get the datetime for. This parameter accepts the location as a string (e.g., Los Angeles, CA), a longitude and latitude (e.g., -31.4173391,-64.183319) , or an IP address (e.g., 82.111.111.111)
Response parameters
The API response is returned in a universal and lightweight JSON format.The JSON Object containing the time and timezone details of the base location from the request.
The JSON Object containing the time and timezone details of the target location from the request.
Present in both in the base_location and target_location objects. The location from the request.
Present in both in the base_location and target_location objects. Decimal of the longitude found for the requested_location.
Present in both in the base_location and target_location objects. Decimal of the latitude found for the requested_location.
Present in both in the base_location and target_location objects. The current date and time of the requested_location.
Present in both in the base_location and target_location objects. Timezone’s name from the IANA Time Zone Database.
Present in both in the base_location and target_location objects. Timezone’s abbreviation, also from the IANA Time Zone Database.
Present in both in the base_location and target_location objects. Timezone’s offset from Greenwich Mean Time (GMT).
Present in both in the base_location and target_location objects. True if the location is currently in Daylight Savings Time (DST).