Consider the following code of HTML & JavaScript
<!DOCTYPE html>
<html>
<body>
<script>
var str = "20990229";
var showDate = new Date();
showDate.setFullYear(str.substring(0, 4))
showDate.setMonth(parseInt(str.substring(4, 6), 10) - 1)
showDate.setDate(str.substring(6, 8))
document.write(showDate)
</script>
</body>
</html>
Output:
Fri Mar 01 2099 16:02:52 GMT+0530 (India Standard Time)
The output is not the correct one, where I am going wrong is not known.
Could anyone tell me where I am going wrong?