Skip to content

Commit 004a856

Browse files
committed
Date string computation function
1 parent 3adc7de commit 004a856

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.eleventy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ module.exports = function(eleventyConfig) {
5353
/* Enable RSS */
5454
eleventyConfig.addPlugin(pluginRss);
5555

56+
/* Date formatting filter */
57+
eleventyConfig.addFilter("formatDate", (date) => {
58+
const d = new Date(date);
59+
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
60+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
61+
return `${months[d.getUTCMonth()]} ${d.getUTCDate()}, ${d.getUTCFullYear()}`;
62+
});
63+
5664
/* Set directories */
5765
return {
5866
dir: {

0 commit comments

Comments
 (0)