Hey there- I have a very simple time script that declares “AM/PM” and “OPEN/CLOSED” depending on the time.
Concerning the “OPEN/CLOSE”, I’m interested in an “OPEN” range between 9:30AM and 4:00PM, and all other times “CLOSED”. I’ve successfully written the script to declare “CLOSED” on the weekends, but need help with the time range. Any help is appreciated! Thanks!
[B]time.js:
[CODE]
function startclock(){
var thetime=new Date();
var dayNames = new Array(“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”);
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var OorC=” “;
var AorP=” “;
//Currently “OPEN” between 9AM-12AM : NEED range from 9:30AM-4:00PM
if (nhours>=9)
OorC=”Open”;
else
OorC=”Closed”;
//closed sat and sun
if (dayNames[thetime.getDay()] == “Sunday”)
OorC=”Closed on Sunday”;
else if (dayNames[thetime.getDay()] == “Saturday”)
OorC=”Closed on Saturday”;
else
OorC=”Open”;
if(nhours>=12)
AorP=”PM”;
else
AorP=”AM”;
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn=”0″+nsecn;
if (nmins<10)
nmins=”0″+nmins;
document.clockform.clockspot.value=” “+nhours+”:”+nmins+”:”+nsecn+” “+AorP+” | “+OorC;
setTimeout(‘startclock()’,1000);
}
[B]html:
[CODE]
<form name=”clockform” style=”padding:0px; margin:0px;”>NYSE TIME |<INPUT TYPE=”text” name=”clockspot” readonly=”readonly” size=”26″ style=”padding:0px; margin:0px;” align=”left”></form>