firefish-archive/config/filters/dates.js
2024-01-11 19:54:55 +00:00

15 lines
546 B
JavaScript

const locale = 'en-GB'; // change this to your locale if you want a different date/time format
module.exports = function (eleventyConfig) {
eleventyConfig.addFilter('dateDisplay', date => new Date(date).toLocaleDateString(locale, {
"dateStyle": "short"
}));
eleventyConfig.addFilter('dateTimeDisplay', date => new Date(date).toLocaleString(locale, {
'dateStyle': 'short',
'timeStyle': 'short',
'hourCycle': 'h12'
}));
eleventyConfig.addFilter('toDate', date => new Date(date));
}