如果 from_date 大于 to_date,则交换日期
Swap dates if from_date is greater than to_date
我有两个约会 from_date 和 to_date。如果 from_date 大于 to_date,如何交换两个日期。这是我试过的代码。谢谢!
$from_date = $con->real_escape_string($_POST['from']);
$to_date = $con->real_escape_string($_POST['to']);
if(strtotime($from_date) > strtotime($to_date)) {
$temp_date = $to_date;
$from_date = $to_date;
$to_date = $temp_date;
}
交换逻辑错误。在将其值更改为 to_date
.
之前,您没有保存 from_date
的值
if(strtotime($from_date) > strtotime($to_date)) {
$temp_date = $from_date;
$from_date = $to_date;
$to_date = $temp_date;
}
我有两个约会 from_date 和 to_date。如果 from_date 大于 to_date,如何交换两个日期。这是我试过的代码。谢谢!
$from_date = $con->real_escape_string($_POST['from']);
$to_date = $con->real_escape_string($_POST['to']);
if(strtotime($from_date) > strtotime($to_date)) {
$temp_date = $to_date;
$from_date = $to_date;
$to_date = $temp_date;
}
交换逻辑错误。在将其值更改为 to_date
.
from_date
的值
if(strtotime($from_date) > strtotime($to_date)) {
$temp_date = $from_date;
$from_date = $to_date;
$to_date = $temp_date;
}