JS converts the date into the number of weeks (work week) of the year

Recent js do form, you want to come work week met according to the date of demand, online check some relevant code, and do the next record here to modify

{
    display: 'Work_Week', name: 'create_time', width: 80, render: function (item) {
      return getYearWeek(item.create_time);
  }
}

 

 

// Get the first few weeks of the year 
        function getYearWeek (DATE) { 
            DATE = formatTimebytype (DATE, ' YYYY-the MM-dd ' ); // convert the date into a format of yyyy-mm-dd 
            DATE = new new a Date (DATE);
             var DATE2 = new new a Date (the Date.getFullYear (), 0 , . 1 );
             var DAY1 = date.getDay ();
             IF (DAY1 == 0 ) = DAY1 . 7 ;
             var DAY2 = date2.getDay ();
             IF (= DAY2 = 0) day2 = 7;
            d = Math.round((date.getTime() - date2.getTime() + (day2 - day1) * (24 * 60 * 60 * 1000)) / 86400000);
            return Math.ceil(d / 7) + 1;
        }

 

 

Guess you like

Origin www.cnblogs.com/Alvis-Lv/p/10986306.html