我有一个网站,提醒用户通过短信支付每月会费。
表:提醒
Duedate | BeforeDue
--------------------------------------------
27 Apr 2017 10:47 AM | 24 Apr 2017 10:47 AM
01 May 2017 10:46 AM | 28 Apr 2017 10:46 AM
我希望在今天的日期介于beforedue和duedate之间时选择所有行
我试过但我的代码出了问题
$ _ POST [今天]的格式为date('d M Y h:i A')
$sq = "SELECT * FROM remind WHERE day3 BETWEEN '$_POST[today]' AND due";
$re = $conn->query($sq);
foreach($re as $row) {
echo ' found: '.$row['day3'];
}
答案 0 :(得分:0)
像这样更新您的查询:
$sq = "SELECT * FROM remind WHERE day3 BETWEEN UNIX_TIMESTAMP(STR_TO_DATE('".$_POST[today]."', '%d %M %Y %h:%i%p')) and UNIX_TIMESTAMP(STR_TO_DATE(Duedate, '%d %M %Y %h:%i%p'))";