12 hour date format

This commit is contained in:
AustinKerr42 2020-08-22 20:02:23 -05:00
parent f98a0392c9
commit ff1791a490

View File

@ -15,18 +15,25 @@ function displayClock() {
'Dec',
];
// Set to true to use a 12 hour date format
var format_12hour = false;
var d = new Date();
var mm = monthNames[d.getMonth()];
var dd = d.getDate();
var min = (mins = ('0' + d.getMinutes()).slice(-2));
var hh = d.getHours();
var ampm = '';
if (format_12hour) {
ampm = hh >= 12 ? ' pm' : ' am';
hh = hh % 12;
hh = hh ? hh : 12; //show mod 0 as 12
}
document.getElementById('hour').innerText = hh;
document.getElementById('separator').innerHTML = ' : ';
document.getElementById('minutes').innerText = min;
document.getElementById('month').innerText = mm;
document.getElementById('day').innerText = dd;
document.getElementById('minutes').innerText = min + ampm;
setTimeout(displayClock, 1000);
}