Documentation
Getting Started
Endpoints
Language Guides
World Time API for Developers
The CurrentTime.now API is a high-precision public service. No API keys or authentication are required for standard endpoints.
JSON Response Schema
{
"timezone": "Europe/London",
"datetime": "2024-05-20T15:30:05.123+01:00",
"utc_datetime": "2024-05-20T14:30:05.123Z",
"utc_offset": "+01:00",
"unixtime": 1716215405,
"dst": true,
"abbreviation": "BST",
"client_ip": "127.0.0.1"
}
World Time API Implementations
JavaScript (Fetch) Snippet
fetch('https://currenttime.now/public/api/ip')
.then(response => response.json())
.then(data => {
console.log('Current Time:', data.datetime);
console.log('UTC Offset:', data.utc_offset);
});
Modern Fetch API for browsers and Node.js 18+.
Node.js (Axios) Snippet
const axios = require('axios');
axios.get('https://currenttime.now/public/api/ip')
.then(response => {
console.log('Time:', response.data.datetime);
console.log('Timezone:', response.data.timezone);
})
.catch(error => console.error(error));
Popular choice for Node.js backend services using Axios.
Python Snippet
import requests
# Get time by specific timezone
response = requests.get('https://currenttime.now/public/api/timezone/Europe/London')
data = response.json()
print(f"London Time: {data['datetime']} ({data['abbreviation']})")
Using the standard requests library.
PHP Snippet
<?php
$json = file_get_contents('https://currenttime.now/public/api/ip');
$data = json_decode($json, true);
echo "Local Time: " . $data['datetime'];
echo "Offset: " . $data['utc_offset'];
?>
Simple integration using file_get_contents.
Ruby Snippet
require 'net/http'
require 'json'
url = URI("https://currenttime.now/public/api/ip")
response = Net::HTTP.get(url)
data = JSON.parse(response)
puts "Time: #{data['datetime']} Offset: #{data['utc_offset']}"
Clean implementation using Net::HTTP.
C# / .NET Snippet
using var client = new HttpClient();
var response = await client.GetStringAsync("https://currenttime.now/public/api/ip");
// Parse with System.Text.Json
Console.WriteLine(response);
Async implementation using HttpClient.
Java Snippet
import java.net.http.*;
import java.net.URI;
public class TimeClient {
public static void main(String[] args) throws Exception {
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://currenttime.now/public/api/ip"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Modern implementation using HttpClient (Java 11+).
Rust Snippet
use reqwest; // reqwest = { version = "0.11", features = ["json"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std.error::Error>> {
let resp = reqwest::get("https://currenttime.now/public/api/ip")
.await?
.json::<serde_json::Value>()
.await?;
println!("Time: {}", resp["datetime"]);
Ok(())
}
Type-safe implementation using the reqwest crate.
Go (Golang) Snippet
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, _ := http.Get("https://currenttime.now/public/api/ip")
var res map[string]interface{}
json.NewDecoder(resp.Body).Decode(&res)
fmt.Printf("Time: %v Offset: %v\n", res["datetime"], res["utc_offset"])
}
High-performance implementation using net/http.
Swift Snippet
import Foundation
let url = URL(string: "https://currenttime.now/public/api/ip")!
let task = URLSession.shared.dataTask(with: url) { data, response, error in
if let data = data, let json = try? JSONSerialization.jsonObject(with: data) {
print(json)
}
}
task.resume()
Native implementation for iOS and macOS.