Show div based on getDay and getHours + getMinutes

Posted by Peta Reardon on Stack Overflow See other posts from Stack Overflow or by Peta Reardon
Published on 2012-11-25T22:16:34Z Indexed on 2012/11/25 23:04 UTC
Read the original article Hit count: 162

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html