<HTML>
<body>
<script>
//dateObj是一个日期对象,days表示给这个日期加多少天,比如说4,5(天)
function dateAdd(dateObj,days){
var tempDate = dateObj.valueOf();
tempDate = tempDate + days * 24 * 60 * 60 * 1000;
tempDate = new Date(tempDate);
return tempDate;
}
function changeDays(datevalues, days) {
//然后使用,创建一个日期对象
var dateValue = datevalues.split("-");
var custArvDateTwoValue = new Date(dateValue[0],dateValue[1]-1,dateValue[2]);
//调用dateAdd,加两天
custArvDateTwoValue = dateAdd(custArvDateTwoValue,days);
var year = custArvDateTwoValue.getFullYear();
var month = custArvDateTwoValue.getMonth() + 1;
var days = custArvDateTwoValue.getDate();
month = month <= 9 ? "0"+month : month;
days = days <= 9 ? "0"+days : days;
document.getElementById("XX").value = year + "-" + month + "-" +days;
}
</script>
增加指定的天数
<input type="text" id="yy" value="" οnclick="changeDays(this.value, 3)"/>
<input type="text" id="XX" value=""/>
</body>
<html>
js增加指定天数
原创mb6434c781b2176 ©著作权
©著作权归作者所有:来自51CTO博客作者mb6434c781b2176的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:java反射效率
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Docker Nacos 升级,增加安全配置
Nacos存在身份认证绕过问题,若用户Nacos未修改 secret.key,则可利用默认secret.key生成JWT Token,从而造成权限绕过访问到相关API接口。
权限控制 Docker Nacos Java 注册中心