首页 > 其他 > 详细

年与日时分秒各种格式 补0位的方法

时间:2018-06-30 18:07:44      阅读:200      评论:0      收藏:0      [点我收藏+]
 let startTime=new Date(this.seachObj.times[0])
 startTime=startTime.getFullYear() + ‘‘ + this.p(startTime.getMonth() + 1) + ‘‘ + this.p(startTime.getDate())+ ‘ ‘+this.p(startTime.getHours()) + ‘:‘ + this.p(startTime.getMinutes()) + ‘:‘ + this.p(startTime.getSeconds())
 let endTime=new Date(this.seachObj.times[1])
 endTime=endTime.getFullYear() + ‘‘ + this.p(endTime.getMonth() + 1) + ‘‘ + this.p(endTime.getDate())+ ‘ ‘+this.p(endTime.getHours()) + ‘:‘ + this.p(endTime.getMinutes()) + ‘:‘ + this.p(endTime.getSeconds())
 
 
补0方法
p (s) {
return s < 10 ? ‘0‘ + s : s;
},

年与日时分秒各种格式 补0位的方法

原文:https://www.cnblogs.com/yn-cn/p/9248081.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!