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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can you help me please. Day of week & Time of day text script

    Hi everyone.

    I know this is my first post but need help if you can please.

    I have the following script

    Code:
     
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    d = new Date();
    dateText = "";
    dayValue = d.getDay();
    if (dayValue == 0)
        dateText += "Sunday";
    else if (dayValue == 1)
        dateText += "Monday";
    else if (dayValue == 2)
        dateText += "Tuesday";
    else if (dayValue == 3)
        dateText += "Wednesday";
    else if (dayValue == 4)
        dateText += "Thursday";
    else if (dayValue == 5)
        dateText += "Friday";
    else if (dayValue == 6)
        dateText += "Saturday";
    monthValue = d.getMonth();
    dateText += " "
    if (monthValue == 0)
        dateText += "January";
    if (monthValue == 1)
        dateText += "February";
    if (monthValue == 2)
        dateText += "March";
    if (monthValue == 3)
        dateText += "April";
    if (monthValue == 4)
        dateText += "May";
    if (monthValue == 5)
        dateText += "June";
    if (monthValue == 6)
        dateText += "July";
    if (monthValue == 7)
        dateText += "August";
    if (monthValue == 8)
        dateText += "September";
    if (monthValue == 9)
        dateText += "October";
    if (monthValue == 10)
        dateText += "November";
    if (monthValue == 11)
        dateText += "December";
    if (navigator.appName.indexOf('Microsoft') != -1)
    dateText += " " + d.getDate() + ", " + (0000 + d.getYear());
    else if (navigator.appName.indexOf('Netscape') != -1)
    dateText += " " + d.getDate() + ", " + (1900 + d.getYear());
    minuteValue = d.getMinutes();
    if (minuteValue < 10)
        minuteValue = "0" + minuteValue
    hourValue = d.getHours();
    if (hourValue < 12)
        {
        greeting = "Good morning!";
        timeText = " at " + hourValue + ":" + minuteValue + 
    " AM. Welcome to our site.";
        }
    else if (hourValue == 12)
        {
        greeting = "Good afternoon!";
        timeText = " at " + hourValue + ":" + minuteValue + 
    " PM. Welcome to our site.";
        }
    else if (hourValue < 17)
        {
        greeting = "Good afternoon!";
        timeText = " at " + (hourValue-12) + ":" + minuteValue +
     " PM. Welcome to our site.";
        }
    else
        {
        greeting = "Good evening!";
        timeText = " at " + (hourValue-12) + ":" + minuteValue + 
    " PM. Welcome to our site.";
        }
    if ((hourValue >= 16-19 && dayValue == 0) || (hourValue < 1 && dayValue == 0))
    {
    document.open();
    document.write("Listen to <i>The A List Chart</i> <strong><em>NOW</em></strong>");
    }
    else
    {
    document.open();
    document.write("Listen to <i>The A List Chart</i> on Sunday from 4pm");
    }
    // -->
          </SCRIPT>
    on <a href="http://www.ctrfm.com/listen.htm">CTR 105.6fm</a>
    So far I have it displaying the text from 4pm but it does not go back to the other text at 7pm

    This is what I would like to happen: (if possible?)
    Between 4pm - 7pm on sundays I would like the following text displayed
    Listen to The A List Chart NOW on CTR 105.6fm
    . Any other time I would like the following text to be displayed
    Listen to The A List Chart on Sunday from 4pm on CTR 105.6
    Is this possible if so how?


    Thanks
    Tom

    tom@jtgameing.co.uk

  • #2
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    You should replace this line:

    Code:
    if ((hourValue >= 16-19 && dayValue == 0) || (hourValue < 1 && dayValue == 0))
    With this one:

    Code:
    if(hourValue >= 16 && hourValue < 19 && dayValue == 0)
    The second line of code requires the hourValue variable to be greater than 16 (4pm) and less than 19 (7pm) and the dayValue variable must be equal to 0 (Sunday).
    My Website: DumpsterDoggy

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    hm...You should use getTimezoneOffset() and the GMT difference (or UTC difference) to have a correct correspondence between user's time zone and the server's time zone....
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thanks Guys

    Thanks every1 for the very quick replies. Im not the best person at javascript so I would like to thank you for your very quick and very helpful advice on a very simple problem. I will highly recommend this site in the future and will be visiting this site lots more in the future.


  •  

    Posting Permissions

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