本文主要是介绍【黄啊码】js:获得当月的日历(包含星期几),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//获得一个月的所有天数 getDaysArray : function(){var result = [];let startDate = new Date();let endDate = new Date();var weeks = ['日','一','二','三','四','五','六'];endDate.setDate(startDate.getDate() + 31);while((endDate.getTime() - startDate.getTime()) >= 0) {let month = startDate.getMonth() + 1 < 10 ? "0" + (startDate.getMonth() + 1).toString() : (startDate.getMonth() + 1);let day = startDate.getDate().toString().length === 1 ? "0" + startDate.getDate().toString() : startDate.getDate().toString();let week = weeks[startDate.getDay()]result.push([{'month': month},{'days':day},{'week': week}]);startDate.setDate(startDate.getDate() + 1);}return result;}
这篇关于【黄啊码】js:获得当月的日历(包含星期几)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!