The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Styleswitch by daytime

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #25413

    Hello everybody!

    You know these CSS-style-switchers where you can click on a daylight and nighttime style? I wanted to have a page where the switching between day.css and night.css happens automatically depending on what time it is. It’s my first PHP, so please laugh but don’t post your laughing :)

    I created a style.php where the intelligent magic happens:

    = 6 AND $fluxcapacitator <= 18) { echo "“;

    else {
    echo ““;


    I know it is very simple. It loads day.css in the time between 6 am and 6 pm. The country I live in is as big as the Neverland Range, so it fits perfectly to what I wanted. But there is some fine stuff like timezone und sunset functions in PHP I still cannot cope with.

    This style.php will be included in the main file daynight.php:


    Day and Night

    This is a test. If it is nighttime, the text will be displayed white on black, otherwise black on white.

    And there are day.css and night.css waiting to be called.

    And what can I say! I works! At least 50%, I have to wait now until it’s 6:01 a.m. tomorrrow morning and see if the page becomes white! PHPeeing rules!

    May be someone detects room for improvement?

    Good night!

    Me -> :D
    PHP -> :lol:

    Rob MacKay

    hey awesome :D thx for posting… you know you could set the time to be in like say 5 mins or something – would save you waiting… ;) or change your computer clock… :)


    Yeah Rob I know, but it is not the same :) Honestly, I changed the if-condition from 6 to 1 for a preview. It worked goog last night, today it displays the night.css though it is 9:45 am. :( I have to revise my code.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.