HI All,
I am trying to setup a state of day where the website will have 4 diferent colors during the day. But with my switch statement below it will just take the second option always. This is case I have put DUSK as the second option and the website will always display the colors of dusk. What is wrong with my code? I tried everything.
[php]
$date = date(“G”);
switch (true) {
// NIGHT 8pm - 4am
case ($date <= 4 || $date >= 20) :
$maincolor = ‘#40AFB5’;
$darkcolor = ‘#08666b’;
$backgroundcolor = $bgcolor;
$backgroundimage = ‘bg’;
$stateofday = ‘Night’;
break;
// DUSK 5pm - 8pm
case ($date <= 20 || $date >= 17) :
$maincolor = ‘#0ea2e8’;
$darkcolor = ‘#016493’;
$backgroundcolor = $bgcolor;
$backgroundimage = ‘bg’;
$stateofday = ‘Dusk’;
break;
// DAWN 4am - 7am
case ($date <= 7 || $date >= 4) :
$maincolor = ‘#d80e0c’;
$darkcolor = ‘#810503’;
$backgroundcolor = $bgcolor;
$backgroundimage = ‘bg’;
$stateofday = ‘Dawn’;
break;
// DAY 7am - 5pm
default:
$maincolor = ‘#f4b41b’;
$darkcolor = ‘#996d02’;
$backgroundcolor = $bgcolor;
$backgroundimage = ‘bg’;
$stateofday = ‘Day’;
}
[/php]