gpt4 book ai didi

jquery - setDate 未显示正确的月份 - jQuery Datepicker

转载 作者:行者123 更新时间:2023-12-01 07:52:49 24 4
gpt4 key购买 nike

设置默认日期不显示我设置的月份,而是月份+1

var defaultDateA1 = new Date(2014,7,1) 
$('#DRdatepicker').datepicker();
$('#DRdatepicker').datepicker('setDate', defaultDateA1);

//whole code below in not working as well
$( "#DRdatepicker" ).datepicker({
readonly: true,
//setDate: new Date(2014,7,1), // First tried here, didn't work
dateFormat: 'yy-mm-dd',
autoSize: true
});

显示08/01/2014

最佳答案

阅读Docs

month: Integer value representing the month, beginning with 0 for January to 11 for December.

所以你必须使用

var defaultDateA1 = new Date(2014,7 - 1, 1) 

日期格式:

$("#DRdatepicker").datepicker({
readonly: true,
dateFormat: 'yy-mm-dd',
autoSize: true
}).datepicker('setDate', new Date(2014, 7 - 1, 1));

DEMO

关于jquery - setDate 未显示正确的月份 - jQuery Datepicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27654343/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com