无法在MySQL-PHP中的数据库列datetime类型中存储值

I wanna save and store date format from $interval in database column which have dattime type. But its not work, in database not show that value.

 if ($no > 1){
     $startdate = new DateTime($lup[$no]);
     $enddate = new DateTime($lup[$no-1]);
     $int = $startdate->diff($enddate);
     $interval = $int->format("%d days, %h hours, %i minutes, and %s seconds  ");
     echo "<td>".$interval."&nbsp;</td>";
    }else
    {
     echo "<td> --- </td>&nbsp;";
    }

 if ($data['id'] == 2){
  $sql = mysql_query("
  INSERT INTO sla (booking_id, approval)
  VALUES ('$booking_id[$no]', '$interval')")
 ;}

Try this

if ($no > 1){
    $startdate = new DateTime($lup[$no]);
    $enddate = new DateTime($lup[$no-1]);
    $int = $startdate->diff($enddate);
    $interval = $int->format("%d days, %h hours, %i minutes, and %s seconds &nbsp;");
    echo "<td>".$interval."&nbsp;</td>";
   }else
   {
    echo "<td> --- </td>&nbsp;";
   }

if ($data['id'] == 2){
 $sql = mysql_query("
 INSERT INTO sla (booking_id, approval)
 VALUES ('".$booking_id[$no]."', '".$interval."')")
;}

The $interval value is a string. If you want to store the data in that format then you should change the data type of your approval column from your sla table into varchar instead of datetime.

Try this:

if ($no > 1){
    $startdate = new DateTime($lup[$no]);
    $enddate = new DateTime($lup[$no-1]);
    $int = $startdate->diff($enddate);
    $interval = $int->format("%d days, %h hours, %i minutes, and %s seconds &nbsp;");
    $dtInterval = $int->format('Y-m-d H:i:s');
    echo "<td>".$interval."&nbsp;</td>";
   }else
   {
    echo "<td> --- </td>&nbsp;";
   }

if ($data['id'] == 2){
 $sql = mysql_query("
 INSERT INTO sla (booking_id, approval)
 VALUES ('$booking_id[$no]', '$dtInterval')")
;}