Javascript Data Type How to - Add days to current date
Question
We would like to know how to add days to current date.
Answer
<!--from w ww . j a v a2s . co m-->
<!DOCTYPE html>
<html>
<head>
<script type=‘text/javascript‘>
window.onload=function(){
var today = new Date();
var newdate = new Date();
newdate.setDate(today.getDate()+29);
document.writeln(newdate);
}
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows:
时间: 2024-10-21 19:07:08