Reputation: 470
I am a beginner at javascript, and I'm looking just for a way to generate a specific day of the week, without any conditions, which I want to practice myself. I'm going through some confusion while reading the documentation. Basically, what I want to tell the javascript is to display a tag at a certain day of the week, at a certain time of the day.
For instance, display on Monday between 19:00-21:00.
I have this and I don't really know how to change whatever is in the element. I feel like I'm not going anywhere with this.
<script type="text/javascript">
element = document.getElementById('broadcast-live')
var datestart = new Date("December 28, 2012 17:00:00")
var date_end = new Date("December 28, 2012 22:00:00")
function DisplayLiveBroadcast()
{
if (new Date => datestart)
{
document.write("<div id=\"broadcast-live\">Live on air (Started Friday, 21:00)<div/>")
}
else if (new Date => date_end)
{
document.write("<div id=\"broadcast-live\"> <div/>")
}
else
{
document.write("<div id=\"broadcast-live\"> <div/>")
}
}
</script>
Upvotes: 1
Views: 684
Reputation: 50728
Try this out, which uses a getDay()
method that returns an integer value referring to the current day: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay
Upvotes: 2