Title: Time based CSS
Last modified: August 18, 2016

---

# Time based CSS

 *  [slavick](https://wordpress.org/support/users/slavick/)
 * (@slavick)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/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)

 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301272)
 * 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](https://wordpress.org/support/users/import/)
   a different stylesheet, but I don’t know it offhand.
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301273)
 * 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.
 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301274)
 * 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 🙂
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301275)
 * 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 …
 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301278)
 * I knew I’d seen this before:
    [http://wordpress.org/support/topic/45714](http://wordpress.org/support/topic/45714)
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301279)
 * I’m so glad there are smart folks out there! Would have never occured to me to
   use php….
 *  Thread Starter [slavick](https://wordpress.org/support/users/slavick/)
 * (@slavick)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301493)
 * 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.

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 7 replies
 * 4 participants
 * Last reply from: [slavick](https://wordpress.org/support/users/slavick/)
 * Last activity: [20 years, 5 months ago](https://wordpress.org/support/topic/time-based-css/#post-301493)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
