I dont know if this is possible but I want to apply a class to something based on a day of the week in PHP. The code would something like this. It is being used to show which day it is within an opening times section on a page.
<?php
$dayoftheweek=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
$whatdayisit=(jddayofweek($dayoftheweek,1));
if ($whatdayisit === Monday){
// SET #monday to class open_colour
}
else if ($whatdayisit === Tuesday) {
// SET #tuesday to class open_colour
}
//.........
?>
I'm not sure if PHP is the way to do this or is there a better way with JS/JQuery...
ADDITION ****
<?php
if ($whatdayisit === Monday){
echo
<div class="opening_times_day_orange">Monday</div> <div class="opening_times_times_orange">07:30 - 23:00 </div>
}
else {
echo
<div class="opening_times_day">Monday</div> <div class="opening_times_times">07:30 - 23:00 </div>
}
?>
I don't fully understand why you would need this, but wouldn't a simple JS solution be any better (if you need it in the front-end anyway):
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
}
then add the value of day to whatever you need with jquery: http://www.w3schools.com/jquery/html_addclass.asp