datepicker格式化时间
只选择年份:
$("#txttYear").datepicker({
changeMonth: false,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yy',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year,month,1));
}
});
选择年月:
$("#txtYearMonth").datepicker({
changeMonth: false,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yymm',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year,month,1));
}
});
选择年月日:
$("#txtDate").datepicker({
changeMonth: false,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yymmdd',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});