firefish-archive/config/filters/dates.js

15 lines
546 B
JavaScript
Raw Normal View History

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