我有一个页面,允许用户选择一个日期范围,然后从数据库中创建一个 pdf 报告,该数据库具有所选范围之间的日期。这工作正常,直到我意识到我不能使用html
input
type date
。只有某些浏览器支持它。所以我正在使用这个 jQuery: http: //jqueryui.com/datepicker/#date-range但是,现在日期格式都是错误的。MySQL 采用日期格式,yyyy-mm-dd
并将其发送为mm/dd/yyyy
. 我尝试过像这样更改格式,但没有任何变化。有任何想法吗?
<body>
<div class="dateselectwrap">
<form action="reports/arrivals.php" method="post">
<div class="dateselect">
<input type="text" class="datepicker" name="start" id="from" required="yes" />
<input type="text" class="datepicker" name="finish" id="to" required="yes" />
<p >Format options:<br />
<select id="format">
<option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
</select>
</p>
</div>
<div class="datesubmit">
<input type="Submit" name="Submit">
</div>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( ".datepicker" ).datepicker();
$( "#format" ).change(function() {
$( ".datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
});
});
</script>
<script>
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
</script>
</form>
</div>
</body>