Country | Time |
---|
updateTime function every second using setInterval setInterval(updateTime, 1000); // Loop through the countries array and create a table row for each one for (var i = 0; i < countries.length; i++) { var country = countries[i]; var now = new Date(); var offset = now.getTimezoneOffset() / 60; var time = now.getUTCHours() + offset + country.timezone; // Create a new table row and cells for the country name and time var row = document.createElement("tr"); var nameCell = document.createElement("td"); var timeCell = document.createElement("td"); // Set the text content and data attributes of the name and time cells nameCell.textContent = country.name; timeCell.textContent = time; timeCell.setAttribute("data-country", country.name); // Append the cells to the row and the row to the time table row.appendChild(nameCell); row.appendChild(timeCell); document.getElementById("time-table").appendChild(row); }
]]>
0 Response to "World Time Zone"
Post a Comment