Format error with datepicker

I created a date picker using an accordion as on this page: docs-demo/datetime.tsx at d47ad2c41f0c036355346ba0ab058f4baedb9d22 · ionic-team/docs-demo · GitHub

While it works fine visually (and the database CRUD is fine), I get this message in the console: ERROR RangeError: Invalid time value. The line mentioned have this code:

return format(parseISO(value), ‘dd MMMM yyyy’);

So, I save the data/load the value from this datepicker to/from Firebase.

I logged the dates before they run through the function and this is what I get back:

2021-07-16T16:23:00+02:00

As far as I know that is an ISO datetime. I would appreciate it if someone can tell me what is wrong with that format.

The problem lies outside what you have posted here. Perhaps your log is deceiving you by stringifying something that isn’t really a string?

$ ts-node
> import {parseISO, format} from "date-fns";
undefined
> let value = "2021-07-16T16:23:00+02:00";
undefined
>  format(parseISO(value), "dd MMMM yyyy")
'16 July 2021'

Thank you @rapropos. You put me on the right path.

To anyone else have this issue. Put your format in an if statement. Here is what I did.

if(value) { console.log(value); return format(parseISO(value), 'dd MMMM yyyy'); } else { return null; }