I have implemented a simple javascript code which displays the date on a page of mine. The thing is, it is set 1 month back. Today (25/12) it shows 25/11. Can you help me find the problem, cause I still have very basic understanding of JS and created this script following a tutorial. Thanks.
<script>
function renderDate() {
var today = new Date();
var d = today.getDate();
var m = today.getMonth();
var y = today.getFullYear();
d = checkTime(d);
m = checkTime(m);
document.getElementById('dateid').innerHTML = d + "/" + m + "<br> <b>" + y + "</b>";
t = setTimeout (function() {renderTime()}, 500);
}
function checkTime(i) {
if (i<10)
{
i = "0" + i;
}
return i;
}
</script>