Skip to content

Commit df7e41d

Browse files
authored
fix: invalid blog dates (#667)
Signed-off-by: Binura Gunasekara <binura@wso2.com>
1 parent b1dbd31 commit df7e41d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/theme/BlogListPage/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ function getCoverImage(content: BlogPostContent): string | undefined {
7878
}
7979

8080
function formatDate(dateStr: string): string {
81-
// Parse as local time by splitting manually — new Date('YYYY-MM-DD') is UTC-based
82-
// and renders one day early for users west of UTC.
83-
const [year, month, day] = dateStr.split('-').map(Number);
81+
// Slice to YYYY-MM-DD before splitting — metadata.date from Docusaurus is a full
82+
// ISO datetime string (e.g. "2025-08-26T00:00:00.000Z"). Parsing as local time
83+
// avoids the UTC off-by-one for users west of UTC.
84+
const [year, month, day] = dateStr.slice(0, 10).split('-').map(Number);
8485
return new Date(year, month - 1, day).toLocaleDateString('en-US', {
8586
year: 'numeric',
8687
month: 'long',

0 commit comments

Comments
 (0)