Solving a date display issue in 11ty templates

I have recently changed the lastmod date in my xml site map to be accurate now that Google are wanting that. Part of what Google wanted was for the page to state the update date on it. I pulled this data from the posts front matter but because I had set an 11ty filter for the sitemap the output on the page was the full UTC:

Updated: 2023-04-03T00:00:00.000

The resolution was to add .toDateString() to the front matter item, dateUpdated, in the template giving me:

dateUpdated.toDateString()

Which displays as:

Updated: Mon Apr 03 2023

Far better!

By Simon Cox Published: Fri, Jul 7, 2023 : Updated: Mon Oct 30 2023

Next short: 11ty draft posts

Previous short: 11ty image shortcode best practice

Latest Shorts

Or all the short articles

Latest articles

Or all the articles