I am trying to add 30 minutes in time but it doesn't display correctly, please help me. Where is the mistake in my code?
The minutes display like a garbage value...
<div id="time"></div>
<script>
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.setMinutes(today.getMinutes()+30);//**here I am adding plus 30 mint but not showing correct**
var s = today.getSeconds();
// add a zero in front of numbers<10
m = checkTime(m);
s = checkTime(s);
//Minutes display like garbage value....
document.getElementById('time').innerHTML = h + ":" + m + ":" + s;
t = setTimeout(function() {
startTime()
}, 500);
}
startTime();
</script>
Please review my code and correct it.