sir no this code is not work show this error

Catchable fatal error: Object of class DateTime could not be converted to string in G:\WampDeveloper\Websites\DefaultWebsite\webroot\d atabase\ins-view.php on line 455

455 Line is:

// set up a row for each record
echo "<tr class=$bgclass>";


and i am using code

PHP Code: 
 $today  =  new DateTime("now");  
                                
                                
// display records in a table
                                        
echo "<div class='mws-panel grid_8'>";
                                        echo 
"<div class='mws-panel-header'><span class='mws-i-24 i-table-1'>Installation Report</span></div>";
                                        echo 
"<div class='mws-panel-body'>";
                                        echo 
"<table class='mws-datatable mws-table' id='example'>";
                                        
                                        
// set table headers
                                                   
                                        
echo "<thead><tr><th>Date</th><th>Service Report No</th><th>Hospital Name</th><th>Description</th><th>Model No</th><th>Serial No</th><th>Date of Installation</th><th>PPM Due date</th><th>Warranty</th></tr></thead>";
                                        
                                        
                                         while (
$row $result->fetch_object()) 
                                        { 
                                                
$bgclass "gradeX";
                                                
$colorPrefix ''
                                                
$colorSuffix ''
                                                
$dateinsrep = new DateTime($row->dateinsrep);
                                                
$dinstall = new DateTime($row->dinstall);
                                                
$date = new DateTime($row->ppmduedate); 
                                                if (
$today >= $date) {$bgclass "expireWarn";}
                                                
$due $date->format("d-m-Y");  
                                                
$due $dateinsrep->format("d-m-Y");
                                                
$due $dinstall->format("d-m-Y");
                                         
                                        
                                                
// set up a row for each record
                                                
echo "<tr class=$bgclass>";
                                                
                                                echo 
"<td>" $dateinsrep->format("d-m-Y") . "</td>";
                                                echo 
"<td>" $row->servicereport "</td>";
                                                echo 
"<td>" $row->hospitalname "</td>";
                                                echo 
"<td>" $row->description "</td>";
                                                echo 
"<td>" $row->model "</td>";
                                                echo 
"<td>" $row->serial "</td>";
                                                echo 
"<td>" $dinstall->format("d-m-Y") . "</td>";
                                                echo 
"<td>" $date "</td>";
                                                echo 
"<td>" $row->warranty "</td>";
                                                echo 
"</tr>";
                                        }