Hoping someone can help me with this.
I’me trying to show/hide a div based on the current time. Here’s the script I’ve been trying to use:
[code]
<script type=”text/javascript”>
// this is used to show/hide a div, etc, on a specified date/time
window.onload = checkDate();
function checkDate() {
var currentTime = Date.now();
var showDate = new Date(2019, 02, 28, 11, 34, 59);
var hideDate = new Date(2019, 02, 28, 11, 39, 59);
// note – the months parameter ranges from 0-11, not 1-12.
// example: new Date(2017, 05, 24, 10, 10, 59) denotes June 24, 2017, 10:10:59 AM
if(currentTime > showDate){
addBlock(document.getElementsByClassName(‘rpt_msg’));
}
if(currentTime > hideDate){
removeBlock(document.getElementsByClassName(‘rpt_msg’));
}
}
function addBlock(item) {
for (var i = 0; i < item.length; i++)
{
if(item[i].parentNode) {
item[i].parentNode.appendChild(item[i]);
}
}
}
function removeBlock(item) {
for (var i = 0; i < item.length; i++)
{
if(item[i].parentNode) {
item[i].parentNode.removeChild(item[i]);
}
}
}
</script>
Any help will be greatly appreciated.. thanks!
SteveMTNO