I have code which needs to state the difference of 2 dates from a table and display the range from start date to end date (in days and weeks) on the same table as well. How can I execute it? I have this code but it doesnt seem to do anything with the dates.The column names of the dates are ‘date_started’ and ‘date_completed’. ex. 2024-07-01 to 2024-07-26
$datetime1 = date_create($_GET['date_started']);
$datetime2 = date_create($_GET['date_completed']);
$interval = date_diff($datetime1, $datetime2);
Then this is the echo that I put in the table:
<td>{$interval->format('%R%a days')}</td>
and the output is = +0 days
but I want the output to be = 3 weeks and 5 days