Jump to content

Changing styles based on season


mrnewt

Recommended Posts

Hi there,

 

My knowledge in PHP is not as great, but I enjoy learning it as much as I can.

Recently I was thinking of trying and create a website that basically has 4 different templates and based on the time of the year/season, the template should change automatically.

 

I tried to find anything similar but I wansn't able to find anything ... yet.

 

Any help that will take me in the right direction (material to look at, functions to consider, etc).

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/208693-changing-styles-based-on-season/
Share on other sites

Just work out the season (this is not exact as some years the season starts a day later).  Then just use the $season var as a template filename or stylesheet filename, etc.

 

if(time() > strtotime('March 19') && time() < strtotime('June 21')) {
$season = 'spring';
}
elseif(time() > strtotime('June 20') && time() < strtotime('September 22')) {
$season = 'summer';
}
elseif(time() > strtotime('September 21') && time() < strtotime('December 21')) {
$season = 'autumn';
}
else {
$season = 'winter';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.