0
点赞
收藏
分享

微信扫一扫

mybatis----小细节

需求:实现日期时间选择组件跨度如果超过限制天数,点击查询则提示超过限制时间

在这里插入图片描述

封装一个方法,传入开始和结束时间以及限制天数,如果超过则返回false

//计算时间跨度是否超过限制天数
    isTimeSpanWithinLimit(startTime, endTime, limitDays) {
      const startDateTime = new Date(startTime)
      const endDateTime = new Date(endTime)
      const timeDifference = endDateTime - startDateTime
      const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24))
      return daysDifference <= limitDays
    }
举报

相关推荐

0 条评论