Results 1 to 10 of 16
Hybrid View
-
17th Jun 2010, 09:54 AM #1OPლ(ಠ益ಠლ)Website's:
extremecoderz.com[php] Time-Based CSS
This small snippet will allow you to use different color schemes (CSS stylesheets) depending on the time of the day! Its not a hugely complicated piece of code, but very creative! Most people have never even thought of the idea!
PHP Code:<?php
// If the time is past seven O'clock then use the night stylesheet instead!
if (date('G') > 19 || date('G') < 7) {
echo '<link rel="stylesheet" type="text/css" href="/static/css/default_night.css" />';
} else {
echo '<link rel="stylesheet" type="text/css" href="/static/css/default_day.css" />';
}
?>jayfella Reviewed by jayfella on . [php] Time-Based CSS This small snippet will allow you to use different color schemes (CSS stylesheets) depending on the time of the day! Its not a hugely complicated piece of code, but very creative! Most people have never even thought of the idea! <?php // If the time is past seven O'clock then use the night stylesheet instead! if (date('G') > 19 || date('G') < 7) { echo '<link rel="stylesheet" type="text/css" href="/static/css/default_night.css" />'; } else { echo '<link Rating: 5
-
17th Jun 2010, 10:02 AM #2Member
Nice
I think I'll find some way to get that working in my forum
-
17th Jun 2010, 10:02 AM #3MemberWebsite's:
wuploadlinks.net fileserve-movies.net fsdown.org
-
17th Jun 2010, 10:07 AM #4The Wise OneWebsite's:
twilight.ws ddlrank.comDo not forget that people that live in a different timezone than the one your server is on will most likely find it weird that the 'evening/night theme' would be turned on at like 10AM their time
EDIT: Nice share thoughI can always be contacted by sending a tweet @twilightws
-
17th Jun 2010, 10:09 AM #5MemberWebsite's:
digitalbattlefield.net imgnow.coWould be cool if you could pull the users time zone that they picked at sign up and change it based on that. Would be I think 1-2 sql calls.
Thanks, I like the idea?Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.?
-
17th Jun 2010, 10:10 AM #6Member
The only downside of that is it'll always use server time. JavaScript can be an alternative to this, since you can fetch local time of the viewer.
Great work with all the posts and tutorials jay.
PHP Code://Alternative 1
$css = date('G') > 19 || date('G') < 7 ? 'default_night.css' : 'default_day.css';
echo '<link rel="stylesheet" type="text/css" href="/static/css/'.$css.'" />';
//Alternative 2
echo date('G') > 19 || date('G') < 7 ? '<link rel="stylesheet" type="text/css" href="/static/css/default_night.css" />' : '<link rel="stylesheet" type="text/css" href="/static/css/default_day.css" />';
-
17th Jun 2010, 10:14 AM #7OPლ(ಠ益ಠლ)Website's:
extremecoderz.comah - im not very good at all with php/js - thanks for the fix - much better
-
17th Jun 2010, 10:15 AM #8Member
Nah not a fix, your method is perfect, I was just showing alternatives.
-
17th Jun 2010, 11:25 AM #9
-
17th Jun 2010, 11:27 AM #10MemberWebsite's:
Doxsters.netyah, a great use of the js woud be maybe showing like a brighter, sunny type banner during the day, and switching to a night one during the night. Its not a big change, nor is it hard to implement, but it looks great
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Long time lurker, first time poster
By Opie in forum IntroductionsReplies: 1Last Post: 27th Sep 2012, 06:53 PM -
[VPS] Need USA based RDP
By masterlog in forum ArchiveReplies: 2Last Post: 19th Apr 2011, 12:57 AM -
[WTB] Vps UK based
By Godly Chaos in forum Hosting DiscussionReplies: 7Last Post: 4th Nov 2010, 05:23 PM -
[VPS] VPS From $8.95/mo USA Based
By webhead2 in forum ArchiveReplies: 4Last Post: 20th Sep 2009, 12:55 AM -
SQL error i get from time to time
By Raven Faust in forum vBulletinReplies: 11Last Post: 27th Aug 2009, 07:54 PM
themaCreator - create posts from...
Version 3.55 released. Open older version (or...