Date

A util function I use to format dates + A component to display dates

FormatDate

TS

export function formatDate(date) {
if (date)
return new Date(date)
.toLocaleDateString('en-us', {
year: 'numeric',
month: 'long',
day: '2-digit',
})
.toString()
}

DateComponent

TS

import { formatDate } from '../lib/formatDate'
export default function DateFormatted({ dateString }) {
const date = formatDate(dateString)
return <time className="capitalize text-xl" dateTime={dateString}>{date}</time>
}