tgadmin/webadmin/static/js/time.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-07-25 12:19:15 +00:00
function updateTime() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const timeString = `${hours}:${minutes}:${seconds}`;
document.getElementById('current-time').textContent = timeString;
}
updateTime();
// Update the time every second
setInterval(updateTime, 1000);
// Initial call to display time immediately
// scripts.js
document.addEventListener('DOMContentLoaded', function () {
function updateTime() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const formattedTime = `${hours}:${minutes}:${seconds}`;
document.getElementById('current-time').textContent = formattedTime;
}
// Update the time immediately
updateTime();
// Update the time every second
setInterval(updateTime, 1000);
});