Skip to content

Instantly share code, notes, and snippets.

@jensgro
Forked from danfascia/11ty_date.js
Created February 9, 2023 22:19
Show Gist options
  • Save jensgro/5bfcfd516549c16800084b092e3a69d5 to your computer and use it in GitHub Desktop.
Save jensgro/5bfcfd516549c16800084b092e3a69d5 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