Tutorials /

Setting a timestamp for posts and RSS feeds in eleventy

Dec 29, 2021 • 🍿 1 min. read

Why do this?

Most of the time my blog posts only use a date, but I noticed in my RSS feed reader that posts with just a date defaulted to showing 00:00 as the time.

My RSS feed code uses something like the following:

    <updated>{{ post.date | dateToRfc3339 }}</updated>

...which parses the date and adds a default of midnight.

Solution:

Change your post date from just a date:

date: 2021-12-29

to a YAML compatible timestamp like:

date: 2021-12-29 17:26:00

ensuring you add the seconds on the end, and the timestamp will show up in your RSS feed reader as 17:26.


Was this useful? →

← Back to Tutorials