title: How to get a date difference as a negative number in PHP?
body: <p>I have this code in php to get the difference between two dates. I'm getting the difference but it's always positive. I need the difference to be negative when the final date has passed. I've tried format(), invert, but nothing seems to work.</p>
  
  <pre><code>function dias_transcurridos($fecha_i, $fecha_f)
  {
  $dias = (strtotime($fecha_i) - strtotime($fecha_f)) / 86400;
  $dias = abs($dias);
  $dias = floor($dias);
  return $dias;
  }
  $hoy = date('Y-m-d');
  </code></pre>
  
  <p>Then I call the code in my loop:</p>
  
  <pre><code>$elPlazo =  dias_transcurridos($row["DateEnd"], $hoy);
  echo "&lt;td&gt;" . $elPlazo . " Días&lt;/td&gt;\n";
  </code></pre>
  
  <p>How can I get $elPlazo (the difference) as a negative number when the end date has passed today?</p>