function clockUpdate() {
var now = new Date();
var hrs = now.getHours();
var mts = now.getMinutes();
var seconds = now.getSeconds();
var milliseconds = now.getMilliseconds();
var month = now.toLocaleString('default', { month: 'long' }); // Get month name
var time = hrs + ':' + addZeroPadding(mts) + ':' + addZeroPadding(seconds) + '.' + addZeroPaddingMilliseconds(milliseconds);
var date = month + ' ' + now.getDate() + ', ' + now.getFullYear() + ' - ' + now.toLocaleDateString("en-US", {
weekday: "long"});
document.getElementById('date').innerHTML = date;
document.getElementById('time').innerHTML = time;
setTimeout(clockUpdate, 1); // Millisecond update
}
// Function to add zero padding to numbers less than 10
function addZeroPadding(num) {
return (num < 10 ? '0' : '') + num;
}
// Function to add zero padding to milliseconds less than 100
function addZeroPaddingMilliseconds(num) {
return (num < 100 ? '0' : '') + (num < 10 ? '0' : '') + num;
}
// Clock Start
clockUpdate();