我有这段PHP代码:
date('Y-m-d', strtotime("-7 days"))
我正在使用在SQL查询中:
$sql="SELECT * from billing_invoices WHERE due_date <= '".date('Y-m-d', strtotime("-7 days"))."' AND (status = 'Unpaid' or status = 'Part Paid') AND statement = '0000-00-00 00:00:00' group by customer_sequence ";
如果日期是2014-12-16
,它将显示2014-12-09
我也想能够运行这个查询:
$sql="SELECT * from billing_invoices WHERE due_date <= '".date($_POST["date"], strtotime("-7 days"))."' AND (status = 'Unpaid' or status = 'Part Paid') AND statement = '0000-00-00 00:00:00' group by customer_sequence ";
但返回的日期是当前日期,而不是距离POSTED
日期-7天的日期。
date(strtotime(date($_POST["date"] . ' -7 days'));
的含义是什么? - putvandedate("Y-m-d", strtotime(date($_POST["date"] . ' -7 days'));
或者在 OP 的情况下date($_POST["date"], strtotime(date($_POST["date"] . ' -7 days'));
- Comum