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:
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:
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< ?php @include("style.php"); ?>
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!
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.