I'd like to add a relative time ... ago into my react blog posts without using moment.js.
The post date is formatted in mysql datatime data type like 2023-02-01 21:25:33
What I tried in the component this:
import { format, formatRelative, subDays } from 'date-fns'
const formatDate = (date) => {
  return formatRelative(subDays(date), new Date())
}
<p>Posted  {formatDate(post.date) }</p>
But I get error:
Unhandled Thrown Error!
Invalid time value
RangeError: Invalid time value
    at format (http://localhost:3000/static/js/bundle.js:11517:11)
    at formatDate (http://localhost:3000/static/js/bundle.js:1341:170)
    at Single (http://localhost:3000/static/js/bundle.js:1396:36)
    at renderWithHooks (http://localhost:3000/static/js/bundle.js:47842:22)
    at mountIndeterminateComponent (http://localhost:3000/static/js/bundle.js:51128:17)
    at beginWork (http://localhost:3000/static/js/bundle.js:52424:20)
    at beginWork$1 (http://localhost:3000/static/js/bundle.js:57387:18)
    at performUnitOfWork (http://localhost:3000/static/js/bundle.js:56656:16)
    at workLoopSync (http://localhost:3000/static/js/bundle.js:56579:9)
    at renderRootSync (http://localhost:3000/static/js/bundle.js:56552:11)
I also could not find any relevant example in the docs. So I'm wondering how can I fix this?