From 7b75fb2e7062020fd9e4e00c74f30cc59178063a Mon Sep 17 00:00:00 2001 From: Dr Griffith Rees Date: Thu, 31 Oct 2024 13:55:06 +0000 Subject: [PATCH] fix: date format on blog list and page --- src/components/BlogCard.astro | 15 ++++++++++++--- src/pages/blog/[...slug].astro | 13 ++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/BlogCard.astro b/src/components/BlogCard.astro index a5e9ef0..cdce2b5 100644 --- a/src/components/BlogCard.astro +++ b/src/components/BlogCard.astro @@ -4,6 +4,17 @@ interface Props { blogPost: CollectionEntry<"blogs">; } const { blogPost } = Astro.props; + +const dateFormatOptions: object = { + year: "numeric", + month: "long", + day: "numeric", + timeZone: "UTC", +}; + +let formattedPublishDate = new Date( + blogPost.data.publish_date, +).toLocaleDateString("en-GB", dateFormatOptions); ---