...

View Full Version : Can you help me please. Day of week & Time of day text script



coxheathdevil
05-15-2006, 08:19 PM
Hi everyone.

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

I have the following script



<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 (http://www.ctrfm.com/listen.htm%22%3ECTR) 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

PremiumBlend
05-15-2006, 09:13 PM
You should replace this line:


if ((hourValue >= 16-19 && dayValue == 0) || (hourValue < 1 && dayValue == 0))

With this one:


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).

Kor
05-16-2006, 05:35 PM
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....

coxheathdevil
05-17-2006, 09:10 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum