![]() |
|
Change the CSS depending on the time - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Design (https://sinister.li/Forum-Design) +--- Forum: Web Design (https://sinister.li/Forum-Web-Design) +--- Thread: Change the CSS depending on the time (/Thread-Change-the-CSS-depending-on-the-time) |
Change the CSS depending on the time - Oxyrus - 08-11-2015 Hello folks, I found this script on a Spanish blog today so I decided to translate it for you. Pretty much what it does is to change the CSS if it's day or night, but you are able to change it because it's really simple. All you have to do is to copy the script within the head tags. Code: <script type="application/javascript">
changeDay = new Date();
hour = changeDay.getHours();
minutes = changeDay.getMinutes();
time = hour + "." + minutes;
if (time >= 19.0 && hour < 23.59 || hour >= 0.0 && hour < 5.59) {
document.write("<link rel='stylesheet' type='text/css' href='night.css' />");
}
else if (hour > 6.0 && hour < 18.00) {
document.write("<link rel='stylesheet' type='text/css' href='day.css' />");
}
else {
document.write("<link rel='stylesheet' type='text/css' href='day.css' />");
}
</script>RE: Change the CSS depending on the time - Kotomi - 08-16-2015 This is very interesting. Can make for a good kind of day/night and looks easy enough to implement it for each member based on their time zone |