标签:
<script>
function dateAdd(strInterval, NumDay, dtDate) {
var dtTmp = new Date(dtDate);
if (isNaN(dtTmp)) dtTmp = new Date();
switch (strInterval) {
case "s":return new Date(Date.parse(dtTmp) + (1000 * NumDay));
case "n":return new Date(Date.parse(dtTmp) + (60000 * NumDay));
case "h":return new Date(Date.parse(dtTmp) + (3600000 * NumDay));
case "d":return new Date(Date.parse(dtTmp) + (86400000 * NumDay));
case "w":return new Date(Date.parse(dtTmp) + ((86400000 * 7) * NumDay));
case "m":return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + NumDay, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
case "y":return new Date((dtTmp.getFullYear() + NumDay), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
}
}
//将日期beginDate加上一天
//strDateList = dateAdd("d", 1, new Date()).toLocaleString();
strDateList = dateAdd("s", 20, ‘2012/09/28‘).toLocaleString();
alert(strDateList);
</script>
标签:
原文地址:http://www.cnblogs.com/mrt-yyy/p/4476013.html