需求 点击保障期的天数 根据起始时间算出结束时间

代码

//点击保障期触发的方法
periodChange(val,id){
this.activeNumperiod=val
this.submitData.endDate=this.getNextDay(this.submitData.startDate,id)+' 00:00:00' //调用格式化日期的方法,将开始时间和要加的天数传进去
},
getNextDay(d,t){
console.log(d,t)//格式为---2019-02-13 3
d = new Date(d);
console.log(d)//格式为---Wed Feb 13 2019 08:00:00 GMT+0800 (中国标准时间)
d = +d + (1000*60*60*24)*t;
console.log(d)//格式为--时间戳1550275200000
d = new Date(d);
console.log(d)//格式为---Sat Feb 16 2019 08:00:00 GMT+0800 (中国标准时间)
return new Date(d).format("yyyy-MM-dd") //格式为"2019-02-16 00:00:00"
},

补充

        // 为Date原型添加时间格式化方法
Date.prototype.format = function (fmt) {
let o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
}
}
return fmt
}

最新文章

  1. penpyxl basic function demo code
  2. C Primer Plus_第8章_字符输入输出和输入确认_编程练习
  3. h5网站和好看的动画网址
  4. C#常用代码集合(1)
  5. WebApi系列~在WebApi中实现Cors访问
  6. ajax头像上传
  7. leetcode:Isomorphic Strings
  8. jquery-easyui使用
  9. linux VM命令下查找
  10. firefox关于about:config的常用配置
  11. iOS开发之视图控制器(UIViewController)
  12. [Unity3D]Unity3D圣骑士当游戏开发商遭遇Mecanim动画系统
  13. ubuntu升级php版本
  14. 设计模式--MVC(C++版)
  15. ASP.NET Core 2.1与2.2 SignalR CORS 跨域问题
  16. PHP左侧菜单栏的管理与实现
  17. 小程序实践(五):for循环绑定item的点击事件
  18. English trip V2 - A 1. Mother tongue 母语 Teacher:Lamb Key: Comparative 比较级 superlative 最高级
  19. postgresql-查看表大小
  20. join() 方法详解及应用场景

热门文章

  1. python之UnittTest模块
  2. deepin 新创建的用户文件管理中挂载点打不开
  3. python的包装和授权
  4. OSI层次介绍
  5. mybatis 批量导入数据到mysql返回批量Id
  6. poj 2914&&hdu 3002 全局最小割Stoer-Wagner算法模板
  7. yii 表单小部件使用
  8. asp.net mvc--identity知识点
  9. BA-siemens-BA模块特性
  10. BA--湿球温度和干球温度的区别