用js怎么一个日期加上天数自动算出日期?比如2013-03-03加上60天算出60天后的日期?
2个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test</title>
<script type="text/javascript">
function convert (start, days)
{
var reg = /[\-\:\.]/g;
var s = start.split (reg);
var sDate = new Date (s[0], s[1], parseInt (s[2]) + days);
return sDate;
}
window.onload = function ()
{
var date = convert ('2013-03-03', 60);
console.info (date.getFullYear () + "-" + date.getMonth () + "-" + date.getDate ());
}
</script>
</head>
<body>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询