Get The Current Season

Get The Current Season
Get the current season based on the United States calendar of seasons and the clock of the PHP server.
function GetSeason()
{
   $SeasonDates = 




array('/12/21'=>'Winter','/09/21'=>'Autumn','/06/21'=>'Summer','/03/21'=>'Spring','/12/31'=>'Winter');
   foreach ($SeasonDates AS $key => $value) // Loop through the season dates
   {
       $SeasonDate = date("Y").$key;
       if (strtotime("now") > strtotime($SeasonDate)) // If we're after the date of the starting season
       {
           return $value;
       }
   }
}
 
echo GetSeason();

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top