【发布时间】:2023-03-09 23:12:01
【问题描述】:
我想在我的日期选择器日历中处理一些日期,我只是不知道如何以我想要的日期格式编写日期。当我在我的代码中使用dateFormat 时,它不起作用。
我的答案可能就在这里,但我不知道在我的代码中在哪里使用它。 http://api.jqueryui.com/datepicker/#utility-formatDate
http://api.jqueryui.com/datepicker/#option-dateFormat
我的代码:
<script>
jQuery(function($) {
$(document).ready(function(){
var sesa1 = new Date(2019, 05, 04); // I want to write this dates in dd-mm-yy format
var sesa2 = new Date(2019, 06, 06); // They curently work in yy-mm-dd format
$(".picker").datepicker({
//dateFormat: 'dd-mm-yy' , // If I uncoment this line the defaultDate will go in year 2024!
defaultDate: '05/07/2019', // It works in format mm-dd-yy and I want it to be in dd-mm-yy
beforeShowDay: function (date) {
var day = date.getDay();
if (date >= sesa1 && date <= sesa2) {
return [(day != 0 && day != 1 ) ? true : false, 'green', 'some text'];
}
return [true, "", "sometext"];
}
});
});
【问题讨论】:
标签: javascript jquery jquery-ui datepicker