Logo Luan Morina
Display content based on the current season demo
TODAY

Sunday: December 22, 2024

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();
?> 
<section class="demo-section">

<div class="demo-container">
<div class="demo-content" style="background-image: url(images/<?php echo $returnCurrentSeason; ?>.jpg);">
<div class="demo-caption">It is <?php echo $returnCurrentSeason; ?> now</div> 
</div>
</div> 

</section> 

CSS

.demo-content {
padding: 3rem 1rem 1rem 1rem;
min-height: 360px;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
   Display a background image based on the current season