I have a project in mind where I would like to change the stylesheet based on time of day. I had initially done this with php, but it grabbed the server’s time. Which was a less than ideal experience considering time zone differences.
I figure javascript may be the best bet to grab the users local time but I am not sure how I would write it. This is similar to what I had in mind, but I am thinking more every 3-6 hours change styles. Thanks in advance for your help!
You could do something like this:
It’s dynamic, based on the number of stylesheets you specify. Currently the number of stylesheets needs to be a factor of 24 (1, 2, 3, 4, 6, 8, 12, 24). You could get rid of this requirement by modifying the code to use minutes and seconds instead of just hours, but that’s too much math for me this morning. 🙂
Edit: Here’s the same script in JS: