automatically change the templates css on a specified date

snark

ahhh thank you very much nr fan

this was exactly the anwser I was hoping for, for everyone that needs more options...

<?php
if ((date('m') == 12) && (date('d') > 4) || ((date('m') == 12) && (date('d') < 6))) {
echo 
'sinterklaas';

}else if ((
date('m') == 12) && (date('d') > 25 || ((date('m') == 1) && (date('d') < 28))) {
echo 
'kerst';


}else{
echo 
'geen sinterklaas, geen kerst';
}

?>

mr-fan

hi snark....don't use JS if you can use PHP  :wink:

i would it try like this:


<?php //colour your life
if ((date('m') == 12) || ((date('m') == 1) && (date('d') < 7))) {
echo 
'<link rel="stylesheet" type="text/css" href="winter.css" id="siteCSS"/>';
}else{
eche ' <link rel="stylesheet" type="text/css" href="default.css" id="siteCSS"/>';
}


or make it with a switch call for all four seasons...

dont' tested...

regards martin

snark

I want to automatically change the css code for a website on for instance x mas, new years day, easter, etc

I found this but I would really like it if I can specify a day of the month, I presume it is quite simple but I am way to dumb ...

    <link rel="stylesheet" type="text/css" href="default.css" id="siteCSS"/>
    <script type="text/javascript">

        // Get current month
        var currDate=new Date();
        var currMonth = currDate.getDate();

        // Month returned by getDate() is 0 to 11 so add 1
        currMonth = parseInt(currMonth) + 1;

        // Based on month assign style sheet name
        var newCSS = "default.css";
        if (currMonth >= 1) newCSS = "winter.css"; // Month is January or greater
        if (currMonth >= 3) newCSS = 'spring.css'; // Month is March or greater
        if (currMonth >= 6) newCSS = 'summer.css'; // Month is June or greater
        if (currMonth >= 9) newCSS = 'fall.css';   // Month is September or greater
        if (currMonth = 12) newCSS = 'winter.css'; // Month is December

        // Assign new style sheet name as the new href for "siteCSS" LINK tag
        document.getElementById('siteCSS').href = newCSS;

    </script>