Skip to content

Instantly share code, notes, and snippets.

@gr36
Created February 14, 2024 08:37
Show Gist options
  • Select an option

  • Save gr36/312b2618815e234127db73c7a7175a33 to your computer and use it in GitHub Desktop.

Select an option

Save gr36/312b2618815e234127db73c7a7175a33 to your computer and use it in GitHub Desktop.
// Add a date filter
eleventyConfig.addFilter("dateFormat", function(date) {
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2); // Adds leading 0 for single digit months
const day = ('0' + date.getDate()).slice(-2); // Adds leading 0 for single digit days
return `${year}/${month}/${day}`;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment