import React from 'react'
import { Date } from 'prismic-reactjs'
/**
Post list item date component
*/
const PostDate = ({ date }) => {
// Format the date to M d, Y
const dateFormat = {
month: 'short',
day: '2-digit',
year: 'numeric'
}
const displayDate = new Intl.DateTimeFormat('en-US', dateFormat).format(Date(date))
It's possible that this might be a quirk of JavaScript dates. Dates from the Prismic API are 00:00 UTC. This blog post explains why JavaScript dates are often off by one day. I can recreate the same error on my computer, and solve it like so:
const displayDate = new Intl.DateTimeFormat('en-US', dateFormat).format(Date(date + " GMT-4"))
Let me know if that helps!
Sam
1 Like
samlittlefair
(Sam Littlefair)
closed , flag & select 'Something Else' to reopen.
6