Why My Eleventy Post Dates Were a Day Early

Nov 20, 2026

When I previewed my blog locally, every post date was a day early. A post dated November 13th said Nov 12, 2026. The live site, built from the same code and content, said Nov 13.

Why Eleventy Dates Show the Day Before

My posts set their date in front matter, the standard Eleventy way:

date: 2026-11-13

Eleventy hands that to JavaScript as a Date, and a date with no time attached is treated as midnight UTC. My date filter then formatted it with Luxon:

DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);

fromJSDate converts to the machine's local time zone. Midnight UTC on the 13th is 7:00 PM on the 12th on the East Coast, so that's the date I got.

So why was production fine? Netlify's build servers run in UTC. Midnight UTC formatted in UTC is still the 13th. The bug was there all along. It only showed up on a machine that wasn't in UTC.

The Fix: Format the Date in UTC

Tell Luxon to format in UTC, the same zone the date was parsed in:

const { DateTime } = require("luxon");

module.exports = function (dateObj) {
  if (typeof dateObj === "string") {
    dateObj = new Date(dateObj);
  }
  return DateTime.fromJSDate(dateObj, { zone: "utc" }).toLocaleString(DateTime.DATE_MED);
};

Now my local build and Netlify agree, regardless of where the build runs.

Fixing datePublished in Structured Data

While I was in there I noticed my post layout was using the same human-readable filter for the structured data search engines read:

"datePublished": "November 13, 2026 at 12:00:00 AM UTC"

Schema.org expects an ISO 8601 date there. I added a tiny filter for it:

eleventyConfig.addFilter("isoDate", (dateObj) => new Date(dateObj).toISOString());

And used it in the layout:

"datePublished": "{{ date | isoDate }}",

Which now produces "datePublished": "2026-11-13T00:00:00.000Z".

If your dates look a day early on your machine but fine in production, check which time zone your date filter formats in.

Thanks for reading! I'd love to hear your thoughts - if you have something you want to share feel free to leave a comment or shoot me an email.

Comments

Leave a Comment