I am trying to retrieve my 2 dates (start date and end date) and to get the difference between them in the same format in wordpress.
My ACF DatePicker fields return:
j F, Y
format that is 20 september, 2021
I tried with the ACF method , but it gives me an error..
$start_date = get_field('start_date');
$date = DateTime::createFromFormat('j F, Y', $start_date);
echo $date->format('j F, Y');
Uncaught Error: Call to a member function format() on bool
Why it doesn't work ?