But they seem to be conflicting creating the following errors
PHP Warning: date_format() expects parameter 1 to be DateTime, boolean given in
PHP Warning: date_create() expects parameter 1 to be string, object given in
OK I’ve got myself a fatal error now as a result of the code below.
$ContractStart1 = new DateTime($data['Contract_Start']);
$ContractEnd1 = new DateTime($data['Contract_End']);
$RenewalDate1 = new DateTime($data['Renewal_Date']);
echo "<td width='80' class='tableData'>".date_format($ContractStart1, 'd-m-Y')."</td>";
echo "<td width='80' class='tableData'>".date_format($ContractEnd1, 'd-m-Y')."</td>";
echo "<td width='80' class='tableData'>".date_format($RenewalDate1, 'd-m-Y')."</td>";
PHP Fatal error: Uncaught exception ‘Exception’ with message ‘DateTime::__construct() expects parameter 1 to be string, object given’ in \CSFFILES11\WEBSITES\live\new_checksafetyfirst\en\csfintranet\contracts.php:912
Stack trace: #0 \CSFFILES11\WEBSITES\live\new_checksafetyfirst\en\csfintranet\contracts.php(912): DateTime->__construct(Object(DateTime)) #1 {main}
thrown in \CSFFILES11\WEBSITES\live\new_checksafetyfirst\en\csfintranet\contracts.php on line 912
As @kreut said above, you need to var_dump your three variables to see what’s wrong. Which is line 912, in the latest code? Error message suggests that they’re not the expected strings.
So it is already a DateTime object and thus you don’t need
$ContractStart1 = new DateTime($data['Contract_Start']);
$ContractEnd1 = new DateTime($data['Contract_End']);
$RenewalDate1 = new DateTime($data['Renewal_Date']);
You can simply use $data['Contract_Start] in replacement of $ContractStart1