I have a database that has columns called start date, start time, end date and end time and want to be able to output the difference so it shows the total time spent per project. Below is the code I have but it shows the error PHP Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (15/08/2021 10:48 AM) at position 0 (1): Unexpected character in view-specific-repair.php:258
On line 258 is the line below
$datetime1 = new DateTime($row->exstdate . ' ' . $row->exstime);
The whole code is below
<?php
$datetime1 = new DateTime($row->exstdate . ' ' . $row->exstime);
$datetime2 = new DateTime($row->exrdate . ' ' . $row->extrime);
$interval = $datetime1->diff($datetime2);?>
Time Spent: <?php echo $interval->format('%Y years, %M months, %D days, %I minutes, %S seconds');?>
I'm not sure what to change it to so it works and outputs the time spent between the start date and start time to the end date and end time