Spaces:
Running
Running
File size: 1,158 Bytes
ce183fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | function updateClock() {
// Get current time adjusted for GMT+2
const now = new Date();
const gmtOffset = 2 * 60 * 60 * 1000; // GMT+2 in milliseconds
const gmtPlus2Time = new Date(now.getTime() + gmtOffset);
// Format time as HH:MM:SS
const hours = String(gmtPlus2Time.getHours()).padStart(2, '0');
const minutes = String(gmtPlus2Time.getMinutes()).padStart(2, '0');
const seconds = String(gmtPlus2Time.getSeconds()).padStart(2, '0');
// Format date
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
};
const dateString = gmtPlus2Time.toLocaleDateString('en-US', options);
// Update DOM
document.getElementById('time').textContent = `${hours}:${minutes}:${seconds}`;
document.getElementById('date').textContent = dateString;
// Timezone information
const timezoneInfo = Intl.DateTimeFormat().resolvedOptions().timeZone;
document.getElementById('timezone').textContent = `GMT+2 (${timezoneInfo})`;
}
// Update clock immediately and then every second
updateClock();
setInterval(updateClock, 1000); |