我有一个网站,提醒用户通过短信支付每月的会费。

表:提醒

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


我想选择今天的日期在早和到期日之间的所有行

我尝试过,但是我的代码出了点问题

$ _POST [today]的格式为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'];
}

最佳答案

像这样更新您的查询:

$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'))";

关于php - 如何根据今天的日期和到期日选择行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43062168/

10-16 15:05