1
I have a algorítimo
done in C
but I decided to do in PHP
. The 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 on a line, the last line contains the negative day number
b) The first date on the line is always the oldest. The year is typed with four digits.
I’ve come this far:
<?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 someone help me solve this problem?
From a look here -> http://blog.thiagobelem.net/calculando-a-diferenca-em-dias-entre-duas-dates/
– MeuChapeu