15 lines
546 B
JavaScript
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));
|
|
} |