fork(1) download
  1. <?php
  2. $dia1 = "12";
  3. $mes1 = "02";
  4. $ano1 = "2011";
  5.  
  6. $dia2 = "20";
  7. $mes2 = "02";
  8. $ano2 = "2013";
  9.  
  10. $data1 = DateTime::createFromFormat("dmY", $dia1 . $mes1 . $ano1);
  11. $data2 = DateTime::createFromFormat("dmY", $dia2 . $mes2 . $ano2);
  12.  
  13. $diff = $data2->diff($data1);
  14.  
  15. echo $diff->format("Diferença de %y anos, %m meses e %d dias.");
  16. echo $diff->format("Diferença total de %a dias");
Success #stdin #stdout 0.03s 24448KB
stdin
Standard input is empty
stdout
Diferença de 2 anos, 0 meses e 8 dias.Diferença total de 739 dias