Fix time bugs
This commit is contained in:
parent
775e9ce72f
commit
1fc2fcbd7e
|
@ -52,12 +52,10 @@
|
||||||
|
|
||||||
const timestampEl = el.querySelector(".timestamp");
|
const timestampEl = el.querySelector(".timestamp");
|
||||||
const time = new Date(timestampEl.textContent);
|
const time = new Date(timestampEl.textContent);
|
||||||
const ampm = time.getHours() > 12 ? "pm" : "am";
|
const ampm = time.getHours() >= 12 ? "pm" : "am";
|
||||||
let hours = time.getHours(); // 0-23
|
let hours = time.getHours() % 12; // 0-23
|
||||||
if (hours === 0) {
|
if (hours === 0) {
|
||||||
hours = 12;
|
hours = 12;
|
||||||
}else {
|
|
||||||
hours %= 12;
|
|
||||||
}
|
}
|
||||||
let minutes = time.getMinutes().toString();
|
let minutes = time.getMinutes().toString();
|
||||||
if (minutes.length < 2) {
|
if (minutes.length < 2) {
|
||||||
|
|
Loading…
Reference in New Issue