title: PHP Date + days
body: <p>I got something like this in MyBB and I want add 5 days to date ($datetime1) with one should be stored in $nowPlus5D.
  Moreover display in $leeft variable how much days, hours, minutes left. difference between (day bought + 5days ) - datenow  </p>
  
  <p>
  
  <pre><code>define("IN_MYBB", 1);
  require_once "global.php";
  
  
  $data_zakupu = $db-&gt;query("
      SELECT timestamp
      FROM ".TABLE_PREFIX."subs
      WHERE txn_id &lt;&gt; '' AND uid=".$mybb-&gt;user['uid']." ORDER BY lid DESC          LIMIT 1;
  ");
  
  
       $dat = $db-&gt;fetch_field($data_zakupu,"timestamp");
       $date_buy = date('d-m-Y H:i:s', $dat); // added h:i:s
  
      // Total bought
      echo '&lt;br&gt;&lt;hr&gt;';
     echo 'Bought date - ' . $date_buy;
    echo '&lt;br&gt;';
  
   $datetime2 = new DateTime('now');
    $datetime1 = new DateTime($date_buy); 
  
   $interval = $datetime1-&gt;diff($datetime2);
  
    $nowPlus5D = $datetime1-&gt;add(new DateInterval('P5D'));
   echo '&lt;hr&gt;&lt;br&gt;';
   echo 'Expiration date - ' . $nowPlus5D-&gt;format('%a days, %h hours, %i, minutes');
   echo '&lt;br&gt;';
  
   $leeft = $nowPlus5D-&gt;diff($datetime1);
   var_dump($leeft);
   echo '&lt;br&gt;';
   echo $left-&gt;format('%a days, %h hours, %i, minutes');
  </code></pre>
  
  <p>and I got that </p>
  
  <pre><code>Bought date - 20-12-2018 18:20:48
  
  Expiration date - %pm 25pm1848, %06 062018000000Tue, 25 Dec 2018 18:20:48 +010048, %20, 12201200000031Europe/Warsaw48
    object(DateInterval)#14 (15) { ["y"]=&gt; int(0) ["m"]=&gt; int(0) ["d"]=&gt; int(0) ["h"]=&gt; int(0) ["i"]=&gt; int(0) ["s"]=&gt; int(0) ["weekday"]=&gt; int(0) ["weekday_behavior"]=&gt; int(0) ["first_last_day_of"]=&gt; int(0) ["invert"]=&gt; int(0) ["days"]=&gt; int(0) ["special_type"]=&gt; int(0) ["special_amount"]=&gt; int(0) ["have_weekday_relative"]=&gt; int(0) ["have_special_relative"]=&gt; int(0) }
  
  Fatal error: Call to a member function format() on integer in /stackoverflow.php on line 42
  </code></pre>