Show div based on getDay and getHours + getMinutes
- by Peta Reardon
I am building a website for a radio station and want to show which presenter is currently on air. I have built a web app that contains data on the presenter: name, photo, bio and start/end times for each weekday.
<div id="presenter1">
<div class="slot">
<div id="sunday-off"> - </div>
<div id="monday-afternoon">12:00 - 15:59</div>
<div id="tuesday-afternoon">12:00 - 15:59</div>
<div id="wednesday-afternoon">12:00 - 15:59</div>
<div id="thursday-afternoon">12:00 - 15:59</div>
<div id="friday-afternoon">12:00 - 15:59</div>
<div id="saturday-morning">06:00 - 08:59</div>
</div>
</div>
What I would like to do is use Javascript functions getDay() and getHours() + getMinutes() to show only the presenter that is scheduled to be on air based on the times specified in the app.
The main part I am having difficulty with is with determining whether this presenter falls within the current time and then showing/hiding the div as necessary.
Any help or guidance on how I can acheive this would be greatly appreciated.