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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Location
    Norwich
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Time Of Day/week/hour Message Help

    Hi i have been looking everywhere and cant seem time to find anything matching,
    what i need is a scheduled message on a website, basically stating days of the week and time and who is live on air. also people maybe on air at 17.30 so i have no idea on how to code this.

    e.g

    Monday 15th August 17:45 - On Air Now, Lee Mills

    so it also refreshes every 1 minute

    Thank you for your help.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,091
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb Consider this ...

    Different forum, but a similar question has been posed and resolved here.
    See: http://www.webdeveloper.com/forum/sh...schedule+times

    Maybe it will help with your problem as well.

    Good Luck!

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Here is something I concocted, and which includes an image of the appropriate DJ :-

    Code:
    <span id = "dj" style="font-size:30px; font-weight:700; font-family:  Arial,Verdana, 
               sans-serif; color: '#FF8000';"></span><img src = "One.gif" id = "theImage">
    
    <script type = "text/javascript"> 
    var show = "No show scheduled at present";
    var GMToffset = -5;  // Your current GMT offset, whether Standard or Daylight	
    var now = new Date();
    var dy = now.getDay(); // day of week 0-6
    now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60);
    var hh = now.getHours();
    
    // The GMT offset ensures that every visitor, regardless of their timezone, will see the schedule
    // that is appropriate for the site owner's local time.
    
    // Tip - for testing purposes you can put here
    //dy = 5;
    //hh = 9;
    // or whatever to check that the right show appears at that day/time.
    
    if (dy >=1 && dy <=5) { // days in Javascript are 0 Sunday - 6 Saturday
    if (hh >=5 && hh <9) {show = "The Tom Joyner Morning Show";  document.getElementById("theImage").src = "Four.gif"}
    if (hh >=9 && hh <14) {show = "Carl T"; document.getElementById("theImage").src = "Two.gif"}
    }
    
    if (dy >=1 && dy <=5) {
    if (hh >=14 && hh <=18) {show ="Tommy C"}
    }
    
    if (dy >= 1 && dy <=4) {
    if (hh >=18 && hh <23) {show = "Keith Sweat"}
    }
    
    if (dy == 5) {
    if (hh >=18 && hh <=23) {show = "G.L.Haywood (House Party)"}  //goes on to midnight
    }
    
    if (dy == 6) { // Saturday Note the two = signs to mean equals
    if (hh >= 6 && hh <9) {show = "The Tom Joyner Morning Show: Right Back At Cha!" }
    if (hh >= 9 && hh <14) {show = "Carl T"}
    if (hh >=14 && hh <20) {show = "George Fisher"}
    if (hh >=20 && hh <22) {show = "Chief Chris Omigee & Momanite Nurse"}
    if (hh >=22 && hh <24) {show = "House Party"}
    } //End of Saturday Shows
    
    if (dy == 0) { //Sunday Shows
    if (hh >= 5 && hh <10) {show = "Porshe Evans (Gospel)"}
    if (hh >=10 && hh <12) {show = "The Cravins Brothers Zydeco and Info Show with Charles & Donald Cravins"}
    if (hh >=12 && hh <17) {show = "George Fisher"}
    if (hh >=17 && hh <21) {show = "Dr. Boogie Live"}
    }  // End of Sunday Shows
    
    var a = "On air now:-  " + show + " \u00A0 \u00A0 \u00A0 \u00A0 ";  // spaces must be separted by Unicode spaces to prevent collapse
    document.getElementById("dj").innerHTML = a;
    </script>

    To update every minute wrap the whole thing in a function named display(),
    then:-
    <body onload = "display()">
    and at the end of the function:-
    setTimeout("display()", 60000); // every 60 seconds
    }
    </script>


    You can use any simple clock script to display the date and time.


    At least once per year, some group of scientists will become very excited and announce that whatever they announced last year about global warming is wrong.
    Last edited by Philip M; 02-08-2010 at 08:29 AM.

  • #4
    New to the CF scene
    Join Date
    Feb 2010
    Location
    Norwich
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, quick one how do you change the pictures i didn't get that part however thank you for you help

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by Leemills View Post
    Thank you, quick one how do you change the pictures i didn't get that part however thank you for you help

    EXAMPLE:-
    if (hh >=9 && hh <14) {show = "Carl T"; document.getElementById("theImage").src = "Two.gif"}
    }

  • #6
    New to the CF scene
    Join Date
    Feb 2010
    Location
    Norwich
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that went way over my head.. sorry, also what if a show is on at 17.30?

    sorry to be lame i do appreciate it

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by Leemills View Post
    that went way over my head.. sorry, also what if a show is on at 17.30?

    sorry to be lame i do appreciate it
    In that case you will need to extend the script to take account of minutes.

    var hh = now.getHours();
    var mn = now.getMinutes();

    and then convert the minutes to a decimal of an hour (e.g. 15 minutes is .25,
    45 minutes is .75 and so on) and add to hh. (e.g. hh = 14 + .5 = 14.5 (hours) = 14.30).

    hh = hh + (mn/60);

    Then:-

    if (hh >=9 && hh <14.5) {show = "Carl T"; document.getElementById("theImage").src = "Two.gif"} // This DJ on from 0900 - 1430


    theImage is naturally an image of the relevant DJ. Here it might be CarlT.jpg.

    But I have the idea that you are trying to run before you can walk.
    Last edited by Philip M; 02-08-2010 at 10:42 PM.

  • #8
    New to the CF scene
    Join Date
    Feb 2010
    Location
    Norwich
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i guess i am, but you and your code is helping me understand it, i thank you for that

  • #9
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you possibly write a full script (like your initial script above) that includes all the changes needed to include minutes. I am trying to make these changes to the script on my website and I am getting all kinds of different results that are not adding up to me. My time zone is -7 Mountain Time also.

    Is the
    var mn = now.getMinutes();

    the only thing you have to add to the top under the hour line or do you have to do something to this line:

    now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset()/ 60);

    and then do you have to change anything on one of the standard lines such as this one:

    if (hh >=17 && hh <21) {show = "Dr. Boogie Live"}

    I'm not real familiar with this type of script so I appreciate any help. I am more used to simple HTML but I absolutely LOVE this script and it's EXACTLY what I have been looking for as well!

    Thank you in advance for any and all help!
    -David.

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by dspurg7310 View Post
    Could you possibly write a full script (like your initial script above) that includes all the changes needed to include minutes.
    Thank you in advance for any and all help!
    -David.
    No. What did your last servant die of? The forum is not a free coding service. I explained how to handle minutes in Post #7.

    BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted.

  • #11
    rgy
    rgy is offline
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's a really cool script!

    When you say "add to hh" followed by hh = hh + (mn/60);
    does that code need to be added to var hh = now.getHours();
    or now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60);
    ?

    I tried changing this
    now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60);

    to

    now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() mn / 60);
    and got a javascript error on load and it didn't seem to take account of the minutes

  • #12
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Code:
    var hh = now.getHours();
    var mn = now.getMinutes();
    hh = hh + (mn/60);
    so for example 14:15 becomes 14.25 hours.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • #13
    rgy
    rgy is offline
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Code:
    var hh = now.getHours();
    var mn = now.getMinutes();
    hh = hh + (mn/60);
    so for example 14:15 becomes 14.25 hours.
    Of course lol it was that simple. I was trying to make big thing out of it and change other portions of the script. That's really cool! Works perfect! Thank you so much for setting that straight for me!

    A lot of other websites have "time of day" scripts but they all just display a message like, Good Morning, Good Afternoon, Good Evening, and Good Night. Plus they don't include the time offset and minutes so they really suck. This script is a lot more elaborate and like Leemills up there, you are helping me understand this stuff too! Thanks again!

  • #14
    rgy
    rgy is offline
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have been using this script for a short while now and it was working ok until the time got to midnight, I then learned that you must use 0 instead of 24 to represent the 12am hour. After I got past that short dilemma, now the script works fine until 11pm and will not display the proper information for the 11pm hour. I thought changing the midnight number from 24 to 0 might have messed with it so I changed it back a forth a few times and still no fix. Is there anything I can do to fix this? I wonder if it has anything to do with an error in internet time or something?

  • #15
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    No, there is no error in internet time.

    Midnight is 0000 hours. 11.00pm is 23:00 hours.

    Without seeing your code it is impossible to say what the problem is, but the fault, dear Brutus, lies not in the stars but ....

    Post your relevant code. It should look something like

    if (hh >= 23) { show = whatever


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

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