尝试这样做:
$sdate = new \DateTime('last saturday');
$edate = new \DateTime();
$query = $this->Orders->find()->where(["Orders.created BETWEEN '.$sdate.' AND '.$edate.'"]);
甚至尝试在php和mySql中使用date_diff
$diff = date_diff($sdate,$edate);
$query = $this->Orders->find()->where(['(DATEDIFF(Orders.created, NOW())) >' => $diff]);
两者似乎都不起作用。任何帮助将不胜感激。谢谢
最佳答案
您可以使用查询生成器:
$sdate = new \DateTime('last saturday');
$edate = new \DateTime();
$query = $this->Orders->find()
->where(function ($exp, $q) use ($sdate, $edate) {
return $exp->between('created', $sdate, $edate);
});
更多信息:Query Builder
关于php - 查找本周创建的记录CakePHP 3,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45264020/