Support » Requests and Feedback » Time based CSS

  • Hi 🙂
    is there a way to change css by time?
    like 18:00 loads a.css 20:00 loads b.css etc..

    Like my header has a nice picture, but i have the same picture in dawn, noon, afternoon and night. Wondering if possible to change them into a night version when the internal clock says 23:00 or so.

    i hope you guys can point me to somewhere, looked like everywhere 🙁

Viewing 7 replies - 1 through 7 (of 7 total)
  • I think you’d have to use a js in order to do this. Check the script sites.

    There may be a way for the browser to determine time and @import a different stylesheet, but I don’t know it offhand.




    php has built in time functions, it would not be that hard to check the time on the server and then use a few if/else (oops) statements to do that. I rotated header images in my old wp1.2 theme quite easily using something similar.


    <div id=”header”>
    if the_time > 1800 then show pic A
    if the_time > 1200 then show pic B
    if the time > 0600 then show pic C
    so the css would load each header as a different class to be shown in the header div.

    The above isn’t ideal but hopefully someone who knows what they are doing will be along soon 🙂




    thats it 🙂

    Instead of calling the image via its name, use a variable — $headerimage, then change the variable depending on the time.

    if the_time > 1200 then $headerimage == path/to/image1
    if the time > 0600 then $headerimage == path/to/image2

    like so …

    I knew I’d seen this before:

    I’m so glad there are smart folks out there! Would have never occured to me to use php….

    thank you guys alot 😀
    changed the css in a php file and now things change on a certain hour.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Time based CSS’ is closed to new replies.