feat: formatted date times one website
This commit is contained in:
parent
dffd14a19f
commit
927f13b623
5 changed files with 51 additions and 17 deletions
|
|
@ -136,6 +136,28 @@
|
|||
</script>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
document.querySelectorAll('.localizable-time').forEach(function(el) {
|
||||
var iso = el.getAttribute('datetime');
|
||||
if (!iso) return;
|
||||
try {
|
||||
var date = new Date(iso);
|
||||
if (isNaN(date.getTime())) return;
|
||||
var options = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
timeZoneName: 'short'
|
||||
};
|
||||
el.textContent = date.toLocaleString(undefined, options);
|
||||
} catch (e) {
|
||||
// Keep server-rendered fallback on error
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<footer>
|
||||
<div>
|
||||
<!-- Social Things -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue