Results 1 to 2 of 2

Thread: Need help with time script

  1. #1
    Join Date
    Jul 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Need help with time script

    Hi, i need help with following script wich i use to to display different content depending on the time of day. But between 0 and 1 nothing is displayed. Whats wrong?
    Code:
    function goto(){ 
    
    var today=new Date(); 
    var hour=today.getHours(); 
    if((hour>0) && (hour<=11)){ 
    
    }
    
    else if((hour>11) && (hour<=18)){ 
    }
    
    else if((hour>18) && (hour<=0)){ 
    }
    
    } 
    
    goto();

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,957
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Nothing is displayed for anything in that code. And in addition to that, this:

    Code:
    else if((hour>18) && (hour<=0)){
    can never be true.

    This would be more efficient:

    Code:
    function goto(){ 
    
    var today=new Date(); 
    var hour=today.getHours(); 
    if (hour < 12) { 
    
    }
    
    else if (hour < 19) { 
    }
    
    else { 
    }
    
    } 
    
    goto();
    Last edited by jscheuer1; 01-23-2014 at 02:28 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Local Time Script - Time Format
    By MizzBia in forum Dynamic Drive scripts help
    Replies: 8
    Last Post: 06-20-2011, 12:37 PM
  2. Local Time script not displaying time at all
    By kittiekat in forum Dynamic Drive scripts help
    Replies: 6
    Last Post: 01-26-2010, 01:46 AM
  3. Resolved "Local Time script" I want to hide the day and just show the time
    By coreyvf in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 11-19-2008, 04:23 PM
  4. Replies: 2
    Last Post: 10-22-2006, 01:25 PM
  5. Local Time Script - Military time?
    By ebrad in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 11-23-2005, 07:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •