Activity Stream
48,167 MEMBERS
6618 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    ლ(ಠ益ಠლ)
    Website's:
    extremecoderz.com

    Default [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

  2.   Sponsored Links

  3.     
    #2
    Member
    Nice

    I think I'll find some way to get that working in my forum

  4.     
    #3
    Member
    Website's:
    wuploadlinks.net fileserve-movies.net fsdown.org
    Thanks, interesting code...

    Please click the image above!

  5.     
    #4
    The Wise One
    Website's:
    twilight.ws ddlrank.com
    Do 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 though
    I can always be contacted by sending a tweet @twilightws

  6.     
    #5
    Member
    Website's:
    digitalbattlefield.net imgnow.co
    Would 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.?

  7.     
    #6
    Member
    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') <  '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') <  '<link rel="stylesheet" type="text/css"  href="/static/css/default_night.css" />' '<link rel="stylesheet" type="text/css"  href="/static/css/default_day.css" />'

  8.     
    #7
    ლ(ಠ益ಠლ)
    Website's:
    extremecoderz.com
    ah - im not very good at all with php/js - thanks for the fix - much better

  9.     
    #8
    Member
    Nah not a fix, your method is perfect, I was just showing alternatives.

  10.     
    #9
    Member
    Website's:
    GFXWebHosting.com WarezJobs.com
    nice code bro..

  11.     
    #10
    Member
    Website's:
    Doxsters.net
    yah, 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"

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Long time lurker, first time poster
    By Opie in forum Introductions
    Replies: 1
    Last Post: 27th Sep 2012, 06:53 PM
  2. [VPS] Need USA based RDP
    By masterlog in forum Archive
    Replies: 2
    Last Post: 19th Apr 2011, 12:57 AM
  3. [WTB] Vps UK based
    By Godly Chaos in forum Hosting Discussion
    Replies: 7
    Last Post: 4th Nov 2010, 05:23 PM
  4. [VPS] VPS From $8.95/mo USA Based
    By webhead2 in forum Archive
    Replies: 4
    Last Post: 20th Sep 2009, 12:55 AM
  5. SQL error i get from time to time
    By Raven Faust in forum vBulletin
    Replies: 11
    Last Post: 27th Aug 2009, 07:54 PM

Tags for this Thread

BE SOCIAL