You are here: irt.org | FAQ | JavaScript | Date | Q1536 [ previous next ]
Try:
<script language="JavaScript"><!-- var splitTime = (8*60)+59; var days = new Array('sun','mon','tue','wed','thu','fri','sat'); var now = new Date(); var dayNum = now.getDay(); // 0 = sun -> 6 = sat var nowTime = (now.getHours()*60) + now.getMinutes(); if (nowTime < splitTime) dayNum-=1; else if (nowTime > splitTime) dayNum+=1; if (dayNum < 0) dayNum = 6; if (dayNum > 6) dayNum = 0; document.write(days[dayNum]); //--></script>