I have algorítimo
done in C
but I decided to do in PHP
. algorítimo
asks for this:
It will calculate the number of days elapsed between two dates including leap years, knowing that:
a) Each pair of dates is read in a row, the last row contains the negative day number
b) The first date in the line is always the oldest. The year is typed with four digits.
I've reached this point:
<?php
$dia1 = 12;
$mes1 = 02;
$ano1 = 2011;
$dia2 = 20;
$mes2 = 02;
$ano2 = 2013;
// dias do ano1 ate ano2
$diasTotalAno = 0;
for ($i=$ano1; $i<$ano2 ; $i++) {
// se for float, nao é bissexto
if (is_float($i/4)) {
$diasTotalAno += 365;
} else {
$diasTotalAno += 366;
}
}
echo "Dias total entre ".$ano1." e ".$ano2." é: ".$diasTotalAno."<br>";
?>
Can anyone help me solve this problem?