WordPress.org

Ready to get started?Download WordPress

Forums

Time based CSS (8 posts)

  1. Slavick
    Member
    Posted 8 years ago #

    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 :(

  2. vkaryl
    Member
    Posted 8 years ago #

    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.

  3. whooami
    Member
    Posted 8 years ago #

    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.

  4. Mark (podz)
    Support Maven
    Posted 8 years ago #

    Psuedo-code:

    <body>
    <div id="header">
    <?php
    if the_time > 1800 then show pic A
    else
    if the_time > 1200 then show pic B
    else
    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 :)

  5. whooami
    Member
    Posted 8 years ago #

    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
    else
    if the time > 0600 then $headerimage == path/to/image2

    like so ...

  6. Mark (podz)
    Support Maven
    Posted 8 years ago #

    I knew I'd seen this before:
    http://wordpress.org/support/topic/45714

  7. vkaryl
    Member
    Posted 8 years ago #

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

  8. Slavick
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.