WorldClockApp

<!DOCTYPE html>

World Time App

World Time App

body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; }

#timeDisplay { margin-top: 20px; font-size: 24px; }

#homeButton { margin-top: 20px; } document.addEventListener(‘DOMContentLoaded’, () => { const locationSelect = document.getElementById(‘locationSelect’); const timeDisplay = document.getElementById(‘timeDisplay’); const homeButton = document.getElementById(‘homeButton’);

function updateTime() {
    const location = locationSelect.value;
    const date = new Date().toLocaleString('en-US', { timeZone: location });
    timeDisplay.textContent = `Current time in ${location.replace('_', ' ')}: ${date}`;
}

locationSelect.addEventListener('change', () => {
    updateTime();
    homeButton.style.display = 'block';
});

homeButton.addEventListener('click', () => {
    timeDisplay.textContent = '';
    homeButton.style.display = 'none';
});

// Display the user's current location time
const userTimeDisplay = document.createElement('div');
document.body.appendChild(userTimeDisplay);
const userTime = new Date().toLocaleString();
userTimeDisplay.textContent = `Your current time: ${userTime}`;

// Initial time display
updateTime(); });