my-website/static/scripts/relativetime.js

12 lines
326 B
JavaScript

"use strict";
Array.from(document.getElementsByClassName("relative-timestamp")).forEach(
function (timestamp) {
if (timestamp?.dateTime) {
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
dateStyle: "long",
timeStyle: "short",
}).format(new Date(timestamp.dateTime));
}
}
);