I am using the jquery datetimepicker and set it up as follows
我正在使用jquery datetimepicker并将其设置如下
$('.fddatetimepicker').datetimepicker({
dateFormat: 'dd/mm/yy'
});
No date is set by default. When I increment either of the hour or minute sliders for the first time by one place, I get the correct time but the date is set to 31/12/1899 in the input textbox. When i move the slider again it changes to the current date which is what I want.
默认情况下不设置日期。当我第一次将小时或分钟滑块增加一个位置时,我得到正确的时间,但输入文本框中的日期设置为31/12/1899。当我再次移动滑块时,它会更改为我想要的当前日期。
Does anyone know why the initial increment of the slider causes the date to be 31/12/1899?
有谁知道为什么滑块的初始增量导致日期为31/12/1899?
I also see this behaviour if i click anywhere on the slider for the first time and then the correct date is displayed when I click on the sliders any further times.
如果我第一次单击滑块上的任何位置,我也会看到此行为,然后当我再次单击滑块时显示正确的日期。
3 个解决方案
#1
just change the format of datetimepicker by using below code. It will work lik charm. I had the same issue and I fixed using that approach in below code.
只需使用下面的代码更改datetimepicker的格式。它会起作用。我有同样的问题,我在下面的代码中修复了使用该方法。
$('.datetimepicker').datetimepicker({
format: "dd-mm-yyyy hh:ii:00P",
autoclose: true
});
#2
You can use the "startDate: new Date" property to start on the current date.
您可以使用“startDate:new Date”属性在当前日期开始。
Example:
$('.fddatetimepicker').datetimepicker({
dateFormat: 'dd/mm/yy',
startDate: new Date
});
More options and properties in: http://xdsoft.net/jqplugins/datetimepicker/
更多选项和属性:http://xdsoft.net/jqplugins/datetimepicker/
#3
Try using format: 'mm/dd/yyyy hh:ii:ss P' The trick is to make sure your date format is the same as what the back-end returns.
尝试使用格式:'mm / dd / yyyy hh:ii:ss P'诀窍是确保您的日期格式与后端返回的格式相同。
#1
just change the format of datetimepicker by using below code. It will work lik charm. I had the same issue and I fixed using that approach in below code.
只需使用下面的代码更改datetimepicker的格式。它会起作用。我有同样的问题,我在下面的代码中修复了使用该方法。
$('.datetimepicker').datetimepicker({
format: "dd-mm-yyyy hh:ii:00P",
autoclose: true
});
#2
You can use the "startDate: new Date" property to start on the current date.
您可以使用“startDate:new Date”属性在当前日期开始。
Example:
$('.fddatetimepicker').datetimepicker({
dateFormat: 'dd/mm/yy',
startDate: new Date
});
More options and properties in: http://xdsoft.net/jqplugins/datetimepicker/
更多选项和属性:http://xdsoft.net/jqplugins/datetimepicker/
#3
Try using format: 'mm/dd/yyyy hh:ii:ss P' The trick is to make sure your date format is the same as what the back-end returns.
尝试使用格式:'mm / dd / yyyy hh:ii:ss P'诀窍是确保您的日期格式与后端返回的格式相同。