I am writing a code to calculate the exact time elapsed between two points in time. This section of the code is supposed to calculate the number of minutes between years 2000 and 2019 (2000 and 2019 will be calculated individually due to the individual months, days etc...). The code is designed to compensate for leap years, however $total_minutes
remain 0 after I run the code.
$years_1 = 2000;
$years_2 = 2019;
$years = $years_2 - $years_1;
$total_minutes = 0;
$n = $years - 2;
$start_year = $years_1 + 1;
for ($year = $start_year; $year <= $n; $year++) {
if ((($year % 4 == 0) && ($year % 100 != 0)) || ($year % 400 == 0)) {
$total_minutes += 527040;
} else {
$total_minutes += 525600;
}
}
How do I solve this problem?