我正在开展一个项目,我必须从数据库中选择日期,今天和明天的所有日期。 日期作为时间戳存储在数据库中。
到目前为止我有这个PHP代码
$hour = 12;
$today = strtotime("$hour:00:00");
$yesterday = strtotime('-1 day', $today);
$tomorrow = strtotime('+2 day', $today);
$today = get_date($today,"timestamp");
$result = $DB->query("SELECT product_id FROM " . DB_PREFIX . "expiry WHERE expiry_date BETWEEN $yesterday AND $tomorrow");
它不起作用。请帮忙。
答案 0 :(得分:1)
试试这个
$tomorrow = strtotime('+1 day', $today);
并且sql更改为此
BETWEEN '".$yesterday."' AND '".$tomorrow."'
并确保
`" . DB_PREFIX . "expiry`
不是那样的
`" . DB_PREFIX . "_expiry`
^---------------did have this or something else like -