我试试这个,但它不工作
{
'conditions' => array('Graph.hid' => $hid, 'DATE(Graph.created) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)', 'Graph.number'=>2)
}
实际上需要前一天的当前时间数据。谁能帮我?提前致谢。
如果您有 DATETIME ,则可以像这样在查询(查找)中使用 BETWEEN :
$yesterday = date("Y-m-d", (time()-86400));
$query = 'SELECT * FROM table WHERE registration between '."'$yesterday 00:00:00'".' and '. "'$yesterday 23:59:59'";
蛋糕之间是:
array('Post.read_count BETWEEN ? AND ?' => array(1,10))
计算最后一天的其他方法:
date("Y-m-d", time() - 86400);
date("Y-m-d", strtotime("yesterday"));
date("Y-m-d", strtotime("-1 day"));