js获取某年某月一共多少天

const getDaysInMonth = (year, month) => {  
    let date = new Date(year, month, 1);  
    return new Date(date.getTime() - 864e5).getDate();  
} 

getDaysInMonth(2018,02)
// 28

  

转载于:https://www.cnblogs.com/lfqcode/p/9660830.html

你可能感兴趣的:(js获取某年某月一共多少天)