<?php
$dia1 = "12";
$mes1 = "02";
$ano1 = "2011";
$dia2 = "20";
$mes2 = "02";
$ano2 = "2013";
$data1 = DateTime::createFromFormat("dmY", $dia1 . $mes1 . $ano1);
$data2 = DateTime::createFromFormat("dmY", $dia2 . $mes2 . $ano2);
$diff = $data2->diff($data1);
echo $diff->format("Diferença de %y anos, %m meses e %d dias.");
echo $diff->format("Diferença total de %a dias");
PD9waHAKJGRpYTEgPSAiMTIiOwokbWVzMSA9ICIwMiI7CiRhbm8xID0gIjIwMTEiOwoKJGRpYTIgPSAiMjAiOwokbWVzMiA9ICIwMiI7CiRhbm8yID0gIjIwMTMiOwoKJGRhdGExID0gRGF0ZVRpbWU6OmNyZWF0ZUZyb21Gb3JtYXQoImRtWSIsICRkaWExIC4gJG1lczEgLiAkYW5vMSk7CiRkYXRhMiA9IERhdGVUaW1lOjpjcmVhdGVGcm9tRm9ybWF0KCJkbVkiLCAkZGlhMiAuICRtZXMyIC4gJGFubzIpOwoKJGRpZmYgPSAkZGF0YTItPmRpZmYoJGRhdGExKTsKCmVjaG8gJGRpZmYtPmZvcm1hdCgiRGlmZXJlbsOnYSBkZSAleSBhbm9zLCAlbSBtZXNlcyBlICVkIGRpYXMuIik7CmVjaG8gJGRpZmYtPmZvcm1hdCgiRGlmZXJlbsOnYSB0b3RhbCBkZSAlYSBkaWFzIik7