• 判断日期是否处于某一个时间的前三个月内


    //封装函数,insertTime为到期时间
    function timeFormat(insertTime) {
      var time = new Date(insertTime);
      var year = time.getFullYear();
      var month = time.getMonth() + 1;
      var date = time.getDate();
      var hour = time.getHours();
      var minute = time.getMinutes();
      var second = time.getSeconds();
      var year_ago, month_ago, date_ago, hour_ago, minute_ago, second_ago;//前三个月的时间
      date_ago = date;
      hour_ago = hour;
      second_ago = second;
      minute_ago = minute;
      if (month == 1) {
        month = 12 + month;
        year_ago = year - 1;
        month_ago = month - 3;
      } else if (month == 2) {
        month = 12 + month;
        year_ago = year - 1;
        month_ago = month - 3;
      } else if (month == 3) {
        month_ago = 12;
        year_ago = year - 1;
      } else {
        month_ago = month - 3;
        year_ago = year;
      }



    month_ago = month_ago.toString();
    month_ago = month_ago[1] ? month_ago : '0' + month_ago;
    date_ago = date_ago.toString();
    date_ago = date_ago[1] ? date_ago : '0' + date_ago;
    hour_ago = hour_ago.toString();
    hour_ago = hour_ago[1] ? hour_ago : '0' + hour_ago;
    minute_ago = minute_ago.toString();
    minute_ago = minute_ago[1] ? minute_ago : '0' + minute_ago;
    second_ago = second_ago.toString();
    second_ago = second_ago[1] ? second_ago : '0' + second_ago;
    var time_ago = year_ago + "-" + month_ago + "-" + date_ago + " " + hour_ago + ":" + minute_ago + ":" + second_ago;
    time_ago = Date.parse(time_ago);
    var nowDate = new Date();
    nowDate = Date.parse(nowDate);
    var differ = nowDate - time_ago;
    return differ;//大于0,则处于前三个月内;小于0,则处于不处于前三个月内
    }
  • 相关阅读:
    SIFT 特征提取算法总结
    Bilateral Filtering(双边滤波) for SSAO(转)
    Meanshift filter实现简单图片的卡通化效果
    HBM内存介绍
    DRAM 内存介绍(三)
    Arduino教程:MPU6050的数据获取、分析与处理
    pitch yaw roll是什么
    通过经纬度坐标计算距离的方法(经纬度距离计算)ZZ
    关于已知两点经纬度求球面最短距离的公式推导
    [Math]理解卡尔曼滤波器 (Understanding Kalman Filter)
  • 原文地址:https://www.cnblogs.com/Andrea-Li/p/8655971.html
Copyright © 2020-2023  润新知