I'm very new to PHP and Im trying to find the right syntax to get the difference between two dates i got as strings. basically i have two dates;
- An estimated completion date ($bcdate)
- An actual completion date ($acdate)
- A difference of two dates ($rfs)
I've tried using methods posted here and from php.net, but i cant seem to get the output for the difference ($rfs) out.
If i output the bc_date and actual_date alone, it works fine.
Heres what Iv been working with so far:
$bcdate = DateTime::createFromFormat('Ymd', get_field ('bc_date'));
$acdate = DateTime::createFromFormat('Ymd', get_field ('actual_date'));
$rfs = $actual_date->diff($bc_date);
echo $acdate->format('j M Y');
echo $bcdate->format('j M Y');
echo $rfs->format('%R%a days');