结束时间和开始时间比较
/**
* 若是要计算开始时间到结束时间相差几天一般要➕1
* 格式:YYYY-MM-DD 或者 YYYY-MM-DD hh:mm:ss
*/
comparisonTime () {
if (this.endTime) {
// 先将小时转化成年月日 时分秒的格式 然后进行对比
let time = this.timeSpan
let yy = new Date().getFullYear()
let mm = new Date().getMonth() + 1
let dd = new Date().getDate()
let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
let F_startTime = yy + '/' + mm + '/' + dd + ' ' + this.startTime + ':' + ss
let F_endTime = yy + '/' + mm + '/' + dd + ' ' + this.endTime + ':' + ss
/**
* 一天等于86400000毫秒
* 一小时3600000毫秒
* 一分钟60000毫秒
* 一秒60000毫秒
*/
let diffValue = (Math.floor((new Date(F_endTime).getTime() - new Date(F_startTime).getTime()) / 60000)) / 30
if (diffValue > this.timeSpan) {
this.$message.error('预约时间最多' + time * 0.5 + '小时')
}
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。