Skip to content

Instantly share code, notes, and snippets.

@danfascia
Created February 15, 2019 12:21
Show Gist options
  • Save danfascia/ead90fe8ef55c9a9369123c21cfcea43 to your computer and use it in GitHub Desktop.
Save danfascia/ead90fe8ef55c9a9369123c21cfcea43 to your computer and use it in GitHub Desktop.
11ty Date formatting filter using Luxon. Usage: {{ date_field | date('dd LLLL yyyy') }}
const { DateTime } = require("luxon");
// date filter formatting using Luxon. Usage: {{ date_field | date('dd LLLL yyyy') }}
eleventyConfig.addFilter("date", (it, format = "LLLL dd, yyyy") => {
return DateTime.fromJSDate(it, { zone: "utc" }).toFormat(format);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment