World Time Script (10 Capitals)
Provide a global perspective for your visitors. This script calculates and displays the current local time for 10 major world capitals in real-time.
Live World Clock
Copy the Script
<div id="world-time-container"></div>
<script>
function updateWorldClocks() {
var cities = [
{name: "London", offset: 0},
{name: "New York", offset: -5},
{name: "Tokyo", offset: 9},
{name: "Paris", offset: 1},
{name: "Dubai", offset: 4},
{name: "Singapore", offset: 8},
{name: "Sydney", offset: 11},
{name: "Los Angeles", offset: -8},
{name: "Cairo", offset: 2},
{name: "Mumbai", offset: 5.5}
];
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
var html = "<ul>";
cities.forEach(function(city) {
var cityTime = new Date(utc + (3600000 * city.offset));
html += "<li>" + city.name + ": " + cityTime.toLocaleTimeString() + "</li>";
});
document.getElementById("world-time-container").innerHTML = html + "</ul>";
}
setInterval(updateWorldClocks, 1000);
</script>
FAQ
Yes. The script gets the UTC time from the visitor's system clock and then offsets it. If the visitor's computer clock is wrong, the world clock will also be off by the same amount.
Yes. You just need to add a new object to the
cities array with the city name and its UTC offset.