今年JS複数の期間の日数に重いです

Date.prototype.format =関数(){
     VAR S = '';
     VAR口=(this.getMonth()+ 1)> = 10(this.getMonth()+ 1):( '0' +(this.getMonth()+ 1));?
     VAR日= this.getDate()> = 10 this.getDate():( '0' + this.getDate());?
     S + = this.getFullYear()+ ' - '。。//获取年份
     S + =口+ " - "; 。//获取月份
     S + =日; //获取日。
     (複数可)を返します。//返回日期。
  };

  関数のgetAll(端を開始){
    VARのARR = [];
    VAR AB = begin.split( " - ");
    VaRのAE = end.split( " - ");
    VaRのデシベル=新しいDate();
    db.setUTCFullYear(AB [0]、AB [1] - 1、AB [2])。
    VARデ=新しいDate();
    de.setUTCFullYear(AE [0]、AE [1] - 1、
    db.getTime unixDb = VAR() - 24 * 60 * 60 * 1000;
    VAR = unixDe de.getTime() - 24 * 60 * 1000 * 60;
    のための(VAR unixDb = K; K <= unixDe;){
      // console.log((新しい新しい日付(のparseInt(K)))形式());
      K = K + 24 * 60 * 60 * 1000;
      。arr.push((新しい新しい日付(のparseInt(K)))形式() );
    }
    戻りARR;
}

はconsole.log(のgetAll( '2018年7月5日'、 '2018年8月5日')); //二つの文字列の配列を取得日の期間

 

 

 

 

 

年間//の初日
//新しいDate(日付).getTime( )文字列の転送スタンプ
するvar yearOneDay =新しい日付(新しい日付 ()のgetFullYear()+ " - " + "01" + " - " + "01")getTime();.
//今日の
VAR =新しい新しい今日日付()getTime();.
昨年の//最初の日
のvar quyearOneDay =新しい日付(新しい日付 ()のgetFullYear() - 1 + ' - ' 。+ '01' + ' - ' + '01')getTime();
//今年のフォーマットの最初の日を取得
VAR =新しい新しいyearOneDaygsを日付(yearOneDay);
//最後の年の最後の日
VAR quyearLastDaygs = yearOneDaygs.setDate(yearOneDaygs。 getDate() - 1);
VAR =新新quyearLastDay日(quyearLastDaygs).getTime();


時間フォーマットされました
関数parseDateStr(V){ 
VAR時間= "";
(!V = NULL && V = ""!)であれば、{
VAR日=新しいDate(V);
Y = date.getFullYear()+ ' - '。
M =(date.getMonth()+ 1 <10 +(date.getMonth()+ 1) '0':date.getMonth()+ 1)+ ' - '。
D =(date.getDate()+ 1 <10 '0' +(date.getDate()):?date.getDate())。
H = date.getHours()+ ':'。
M = date.getMinutes()+ ':'。
S =のdate.getSeconds()。
時間= Y + M + D。
}
時刻を返します。
}

//去重复
関数qctimes(ARR){
arr.forEach(関数(アイテム){
戻りa.includes(項目) '':a.push(項目);
});
返します。
}

おすすめ

転載: www.cnblogs.com/sx00/p/10978969.html
おすすめ