【发布时间】:2019-05-14 09:24:23
【问题描述】:
这是我从一些网站获得的 javascript 代码。但它只是给了我像 (01-06-2019/01-07-2019/01-08-2019) 这样的日期月份和年份,我想输出正确的日期。
我可以在这里改变什么?
<script type="text/javascript">
$("#monthPicker").datepicker({
dateFormat: 'MM yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
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).val($.datepicker.formatDate('MM yy', new Date(year, month, 1)));
//$(this).datepicker('setDate', new Date(year, month, 1));
$(this).datepicker('refresh');
}
});
$("#monthPicker").focus(function () {
$(".ui-datepicker-calendar").show();
$("#ui-datepicker-div").position({
my: "center top",
at: "center bottom",
of: $(this)
});
});
</script>
【问题讨论】:
-
你想以哪种格式显示日期?
-
@MannanBahelim 日月年