日期时间选择器呈现不正确
Datetimepicker Render Incorrectly
我尝试在 datetimepicker 上实现 minDate 属性,但日期呈现不正确。
最小日期:新日期()
$(.datepicker).datetimepicker({
format : 'MM/DD/YYYY',
midDate : new Date()
});
但结果却出乎我的意料。
https://i.imgur.com/SZdkrt1.jpg
@Fajar-Taufik
根据你的问题,我给你的解决方案如下代码所示。我在我的系统中尝试了这段代码,它是有效的。
<html>
<head>
<title>Datepicker - functionality</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.12.1/themes/ui-lightness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
minDate: "-1w"});
$('#datepicker2').datepicker({
dateFormat: "yy-mm-dd",
minDate: new Date('2019-08-06')
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
<p>Date: <input type="text" id="datepicker2"></p>
</body>
</html>
希望这段代码对你有用。
谢谢。
不是
midDate : new Date()
其
minDate : new Date()
我尝试在 datetimepicker 上实现 minDate 属性,但日期呈现不正确。
最小日期:新日期()
$(.datepicker).datetimepicker({
format : 'MM/DD/YYYY',
midDate : new Date()
});
但结果却出乎我的意料。 https://i.imgur.com/SZdkrt1.jpg
@Fajar-Taufik
根据你的问题,我给你的解决方案如下代码所示。我在我的系统中尝试了这段代码,它是有效的。
<html>
<head>
<title>Datepicker - functionality</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.12.1/themes/ui-lightness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
minDate: "-1w"});
$('#datepicker2').datepicker({
dateFormat: "yy-mm-dd",
minDate: new Date('2019-08-06')
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
<p>Date: <input type="text" id="datepicker2"></p>
</body>
</html>
希望这段代码对你有用。
谢谢。
不是
midDate : new Date()
其
minDate : new Date()