Get World Time in PHP
PHP servers often rely on the configured server time, which may differ from your users' actual location. By fetching our JSON API, you can display precise local times dynamically without changing server configs.
PHP
<?php
$timezone = "Europe/London";
$url = "https://time.now/developer/api/timezone/" . $timezone;
// Fetch JSON data
$json = file_get_contents($url);
$data = json_decode($json, true);
if ($data) {
echo "Current time in " . $data['timezone'] . ": " . $data['datetime'];
echo "<br>Unix Timestamp: " . $data['unixtime'];
} else {
echo "Failed to fetch time data.";
}
?>
Why use Time.Now for Backend?
- Compatible with `json_decode`
- Zero external dependencies
- Lightweight response for fast rendering