我想以dd / mm / yyyy格式获取一个月引导日期选择器的当前开始日期和结束日期 例如,我的日历中的当前月份是2月,那么我的值将是
start date:1/02/2017
and
end date:28/02/2017
同时如果我去下个月进行游行那么我的情景就是
start date:1/03/2017
and
end date:31/03/2017
我在控制台中输出了值,但我得到的是这个
29/1/2017
30/1/2017
31/1/2017
1/2/2017
2/2/2017
....
28/2/2017
...
11/3/2017
当前日期选择器
中显示的日期列表这是我的代码
var active_dates = ["1/2/2017", "5/2/2017"];
$('#datepicker').datepicker({
inline: true,
sideBySide: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
beforeShowDay: function (date) {
var d = date;
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1; //Months are zero based
var curr_year = d.getFullYear();
var formattedDate = curr_date + "/" + curr_month + "/" + curr_year
console.log(formattedDate);
if ($.inArray(formattedDate, active_dates) != -1) {
return {
classes: 'activeClass'
};
}
return;
}
});
答案 0 :(得分:0)
I did fixed it with datejs
This is alerting the first day:
var fd = Date.today().clearTime().moveToFirstDayOfMonth();
var firstday = fd.toString("MM/dd/yyyy");
alert(firstday);
This is for last day:
var ld = Date.today().clearTime().moveToLastDayOfMonth();
var lastday = ld.toString("MM/dd/yyyy");
alert(lastday);