const firstDate = parseISO(event.start_date); // Here I already have the formatted date
const secondDate = parseISO(event.end_date); // Here I already have the formatted date
const distance = formatDistance(
firstDate ,
secondDate
);
I need to pass the distance between these two dates that are already formatted. As it is he points me out.
this difference with all data (date and time)
here is an example of what I get at api
"start_date": "2020-09-23 11:24:14", "end_date": "2020-09-24 17:47:41",
I don't know a whole lot about
date-fns
but sinceparseISO()
returns aDate
object, you can do math with the result of.getTime()
to get the difference in milliseconds: