Hi,
I have this code that displays current date and then also the current date plus 4 days. How do I get the plus 4 days date to refresh every second like the current time. When the time passes midnight and is a new day the plus 4 days date is not updating.
Thanks
I have this code that displays current date and then also the current date plus 4 days. How do I get the plus 4 days date to refresh every second like the current time. When the time passes midnight and is a new day the plus 4 days date is not updating.
Thanks
HTML:
<!DOCTYPE html>
<html>
<script type="text/javascript">
function display_c(){
var refresh=1000; // Refresh rate in milli seconds
mytime=setTimeout('display_ct()',refresh)
}
function display_ct() {
var strcount
var x = new Date()
document.getElementById('ct').innerHTML = x;
tt=display_c();
}
</script>
<body onload=display_ct();>
<h3>Today is:</h3>
<span id='ct' ></span>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h3>ELITT Day is:</h3>
<p id="date"></p>
<script>
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf());
dat.setDate(dat.getDate() + days);
return dat;
}
var dat = new Date();
document.getElementById("date").innerHTML = (dat.addDays(4));
(dat.addDays(4))
</script>
</body>
</html>
Last edited by a moderator: