PHP

Background that adapts to the current season

TODAY

Friday: February 28, 2025

winter

PHP
<?php
function GetCurrentSeason() {

$seasonDates = array('/12/21'=>'winter',
'/09/21'=>'autumn',
'/06/21'=>'summer',
'/03/21'=>'spring',
'/01/01'=>'winter');

foreach ($seasonDates AS $seasonKey => $seasonValue) {
$seasonDate = date("Y").$seasonKey;
if (strtotime("now") > strtotime($seasonDate)) {
return $seasonValue;
}

}

}
$returnCurrentSeason = GetCurrentSeason();
?>
HTML and PHP
<section style="background: url(images/<?php echo $returnCurrentSeason; ?>.jpg);"> </section>