The number of days in a year js multiple time periods to heavy

Date.prototype.format = function() {
     var s = '';
     var mouth = (this.getMonth() + 1)>=10?(this.getMonth() + 1):('0'+(this.getMonth() + 1));
     var day = this.getDate()>=10?this.getDate():('0'+this.getDate());
     s += this.getFullYear() + '-'; // 获取年份。
     s += mouth + "-"; // 获取月份。
     s += day; // 获取日。
     return (s); // 返回日期。
  };

  function getAll(begin, end) {
    var arr = [];
    var ab = begin.split("-");
    var ae = end.split("-");
    var db = new Date();
    db.setUTCFullYear(ab[0], ab[1] - 1, ab[2]);
    var de = new Date();
    de.setUTCFullYear(ae[0], ae[1] - 1,ae [2]);
    db.getTime unixDb = var () - 24 * 60 * 60 * 1000;
    var = unixDe de.getTime () - 24 * 60 * 60 * 1000;
    for (var unixDb = K; K <= unixDe;) {
      // the console.log ((new new a Date (the parseInt (K))) the format ().);
      K = K + 24 * 60 * 60 * 1000;
      . arr.push ((new new a Date (the parseInt (K))) the format () );
    }
    return ARR;
}

the console.log (the getAll ( '2018-07-05', '2018-08-05')); // Get an array of two strings day period

 

 

 

 

 

The first day of the year period // 
// new Date (date) .getTime ( ) String transfer stamp
var yearOneDay = new Date (new Date () getFullYear () +. "-" + "01" + "-" + "01") getTime ();.
// today
var = new new today a Date () getTime ();.
// The first day of last year
var quyearOneDay = new Date (new Date (). getFullYear () - 1 + '-' . + '01' + '-' + '01') getTime ();
// get the first day of this year's format
var = new new yearOneDaygs a Date (yearOneDay);
// the last day of last year
var quyearLastDaygs = yearOneDaygs.setDate (yearOneDaygs. getDate () -. 1);
var = new new quyearLastDay a Date (quyearLastDaygs) .getTime ();


time formatted
function parseDateStr(v) {
var time = "";
if (v != null && v != "") {
var date = new Date(v);
Y = date.getFullYear() + '-';
M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
D = (date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate());
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
time = Y + M + D;
}
return time;
}

//去重复
function qctimes(a, arr) {
arr.forEach(function (item) {
return a.includes(item) ? '' : a.push(item);
});
return a;
}

Guess you like

Origin www.cnblogs.com/sx00/p/10978969.html