jlhaslip, on Nov 12 2007, 11:36 PM, said:
Here is another, simpler, method. Serve a different CSS file based on the time of day.
Replace your existing link tag with the following php code.
You will need 3 CSS files named according to the file names used in the script, of course, with the background image changed in each one according to the preferred design.
Replace your existing link tag with the following php code.
You will need 3 CSS files named according to the file names used in the script, of course, with the background image changed in each one according to the preferred design.
<?php
$hour = date('H');
if ($hour < 12 ) {
echo '<link rel="stylesheet" type="text/css" href="morning.css" />;
}
elseif ($hour < 17 ) {
echo '<link rel="stylesheet" type="text/css" href="day.css" />;
}
else {
echo '<link rel="stylesheet" type="text/css" href="night.css" />;
}
?>
Untested. No example available.That is actually the way I do my styles for different times of years, except because I'm too lazy to test on my website i do it in javascript, but it's almost the exact same code. Thanks for the code though, I can see it now.















