fork(1) download
  1. <?php
  2.  
  3.  
  4. $startRaw = '2013-05-10 12:04:58';
  5. $start = DateTime::createFromFormat('Y-m-d H:i:s', $startRaw );
  6.  
  7. $endRaw = date("2015-05-10 12:04:58");
  8. $end = DateTime::createFromFormat('Y-m-d H:i:s', $endRaw );
  9.  
  10. $diff = $start->diff($end);
  11.  
  12. echo 'Difference: ' . $diff->format('%y years') . "\n";
  13.  
Success #stdin #stdout 0.03s 24448KB
stdin
Standard input is empty
stdout
Difference: 2 years