Fix time bugs

This commit is contained in:
MatthiasSaihttam 2020-09-08 12:32:00 -04:00
parent 775e9ce72f
commit 1fc2fcbd7e
1 changed files with 2 additions and 4 deletions

View File

@ -52,12 +52,10 @@
const timestampEl = el.querySelector(".timestamp");
const time = new Date(timestampEl.textContent);
const ampm = time.getHours() > 12 ? "pm" : "am";
let hours = time.getHours(); // 0-23
const ampm = time.getHours() >= 12 ? "pm" : "am";
let hours = time.getHours() % 12; // 0-23
if (hours === 0) {
hours = 12;
}else {
hours %= 12;
}
let minutes = time.getMinutes().toString();
if (minutes.length < 2) {