const englishWeekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; function updateTime() { const xhr = new XMLHttpRequest(); xhr.open("HEAD", location.href.toString(), true); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { const serverDate = new Date(xhr.getResponseHeader("Date")); const weekday = serverDate.getDay(); // document.getElementById('time').innerHTML = serverDate.toLocaleString() + ' ' + englishWeekdays[weekday]; document.getElementById('time').innerHTML = serverDate.toLocaleString() ; } }; xhr.send(null); } setInterval(updateTime, 10000); |