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\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de\" lang=\"de\" />
<p>This is a test. If it is nighttime, the text will be displayed white on black, otherwise black on white.</p>
</body>
</html>
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!
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.
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:
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!
Rúna
Me -> :D
PHP -> :lol: