【发布时间】:2015-08-08 23:24:09
【问题描述】:
我正在使用 jQueryUI 日期选择器,这里是代码。
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<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 action="{LINKTO_EXPORT}" method="post">
<h1>{EXPORT_CSV}</h1>
<label for="from">from</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">
<input type="submit" value="{EXPORT_TEXT}">
</form>
当我“发布”“发件人”和“收件人”时,
$fromstr = $_POST["from"];
$tostr = $_POST["to"];
$from = date('Y-m-d H:i:s',strtotime($fromstr." 02:00:00"));
$to = date('Y-m-d H:i:s',strtotime($tostr." 02:00:00"));
to 已正确转换,即2015-06-13 02:00:00 但from 没有。它返回了6/1/2015 2:00。为了确保获取正确的值,我回显了$fromstr 和$tostr。
$fromstr 返回6/1/2015
$tostr返回06/13/2015
为什么from 返回m/d/yyyy 而to 返回mm/dd/yyyy?那么如何将 m/d/yyyy 字符串转换为时间戳?请帮忙,谢谢!
【问题讨论】:
-
这些日期对我来说很好。
-
您是否尝试过在您的
.datepicker()中使用dateFormat: "mm/dd/yyy"以确保您的格式一致
标签: php jquery jquery-ui datetime datepicker