forked from MarseyWorld/MarseyWorld
shorter time code that achieves same results and respects locale's AM-PM preference
parent
d0ef9768ed
commit
f8c177172d
|
@ -1,8 +1,5 @@
|
||||||
function formatDate(d) {
|
function formatDate(d) {
|
||||||
const hour = ("0" + d.getHours()).slice(-2);
|
return d.toLocaleTimeString()
|
||||||
const minute = ("0" + d.getMinutes()).slice(-2);
|
|
||||||
const second = ("0" + d.getSeconds()).slice(-2);
|
|
||||||
return hour + ":" + minute + ":" + second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const e of timestamps) {
|
for (const e of timestamps) {
|
||||||
|
|
|
@ -231,14 +231,8 @@ function showmore(t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(d) {
|
function formatDate(d) {
|
||||||
const year = d.getFullYear();
|
const options = {year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZoneName: 'short'};
|
||||||
const monthAbbr = d.toLocaleDateString('en-us', {month: 'short'});
|
return d.toLocaleTimeString([], options)
|
||||||
const day = d.getDate();
|
|
||||||
const hour = ("0" + d.getHours()).slice(-2);
|
|
||||||
const minute = ("0" + d.getMinutes()).slice(-2);
|
|
||||||
const second = ("0" + d.getSeconds()).slice(-2);
|
|
||||||
const tzAbbr = d.toLocaleTimeString('en-us', {timeZoneName: 'short'}).split(' ')[2];
|
|
||||||
return day + " " + monthAbbr + " " + year + " " + hour + ":" + minute + ":" + second + " " + tzAbbr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamps = document.querySelectorAll('[data-time]');
|
const timestamps = document.querySelectorAll('[data-time]');
|
||||||
|
|
Loading…
Reference in New Issue