View Single Post
Old 24 Jun 2022, 01:22 PM   #5
somdcomputerguy
Cornerstone of the Community
 
Join Date: Jun 2004
Location: Rupert, WV
Posts: 881
I haven't made this script '$startYear changeable' other than just editing the file itself. I've written a few other PHP scripts, some useful but most both useless and useful..

- bruce

http://somdcomputerguy.com/leaps.php
PHP Code:
<? 
$startYear 
"1967";
$endYear   date("Y");
$leapYears = array();

echo 
"<center><h2>A list of leap years since $startYear</h2>";

for(
$i $startYear$i <= $endYear$i++){ if(($i == 0) and ($i 100 != 0) or ($i 400 == 0)){ $leapYears[] = $i; }}

foreach(
$leapYears as $leapyear){ echo "$leapyear<br>"; }

echo 
"<h3>So, there appears to have been " count($leapYears) . " leap years since $startYear.</h3>";

if(
$leapyear == $endYear){
    echo 
"<h4>This year is a leap year.</h4></center>";
    } else {
        echo 
"<h4>This year, <small>" date("Y") . "</small>, is not a leap year.</h4></center>";
    }
?>

Last edited by somdcomputerguy : 24 Jun 2022 at 01:41 PM. Reason: made code font size smaller
somdcomputerguy is offline   Reply With Quote