Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Day / Time message.. HELP!!

    Help!

    I need to be able to have a message displayed based on the DAY OF THE WEEK AND the CURRENT TIME.

    For example:

    On Friday from 9pm-10pm, it will say "Test 1"

    On Saturday from 9pm-10pm, it will say "Test 2"

    I have found several scripts that will display a message based on ONLY the time or ONLY the date. I'm having a hard time finding a script that will do both.


  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function showMessage()
    {
        var d = new Date();
        var day = d.getDay();     // Note: Sunday=0, Monday=1, etc...
        var hour = d.getHours();  // 24-hour time
    
        switch( true )
        {
            case ( day == 5 && hour == 9 ) :
            {
                // Do Friday 9am - 10am stuff here
                break;
            }
            case ( day == 6 && hour == 9 ) :
            {
                // Do Satruday 9am - 10am stuff here
                break;
            }
        }    
    }
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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