Difference between dates with PHP
19 febbraio 2008, 17:07 PHP , tips and tricks February 19, 2008, 17:07Calculate the difference between two dates in terms of days is very, very easy with PHP. Here's the function that returns the calculation:
function days_diff( $giornoA, $meseA, $annoA, $giornoB, $meseB, $annoB )
{
$timestampA = mktime(0, 0, 0, $meseA, $giornoA, $annoA);
$timestampB = mktime(0, 0, 0, $meseB, $giornoB, $annoB);
$diff = floor(($timestampB - $timestampA) / (3600 * 24));
return $diff;
}function days_diff( $giornoA, $meseA, $annoA, $giornoB, $meseB, $annoB ) The values to be passed to the function are the following:
{
$timestampA = mktime(0, 0, 0, $meseA, $giornoA, $annoA);
$timestampB = mktime(0, 0, 0, $meseB, $giornoB, $annoB);
$diff = floor(($timestampB - $timestampA) / (3600 * 24));
return $diff;
}
- $ GiornoA, meseA $, $ annoA: day, month and year (int) date less
- $ GiornoB, meseB $, $ annoB: day, month and year (int) date more














