我想获取一个月的所有日期。格式类似于 {2019-9-17} 但我不想在那天包括星期日。假设我一个月有 30 天,假设我们有 4 个星期日,我只想打印除星期日之外的所有日期。
PS:我正在使用 datepicker,在 jQuery datepicker 的帮助下传递月份和年份
onClose: function() {
var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
var my_month=(parseInt(iMonth) + 1);
console.log('datepicker month='+my_month);
$('.test').empty();
var date = new Date();
var month = date.getMonth();
var current_date = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
//console.log(current_date);
date.setDate(1);
var all_days = [];
var week = [];
while (date.getMonth() == month) {
// Getting all days from here and storing in array named as all)days();
var d = date.getFullYear() + '-' + my_month.toString().padStart(2, '') + '-' + date.getDate().toString().padStart(2, '0');
all_days.push(d);
date.setDate(date.getDate() + 1);
//$('.test').append(all_days);
}
console.log(all_days);
$(document).ready(function() {
$('#txtDate').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM yy',
minDate:0,
onClose: function() {
var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
var my_month=(parseInt(iMonth) + 1);
console.log('datepicker month='+my_month);
慕的地8271018
12345678_0001
相关分类