显示本周日期为CakePHP的记录

显示本周日期为CakePHP的记录,cakephp,records,Cakephp,Records,我想知道如何显示日期与本周相符的记录。例如,如果我们有从12.05到18.05的天数,并且我们在表中有值为12.05的行和值为18.05的行的记录 我试着这么做,但它并没有按我想要的那样工作。问题在于,仅当“开始”值与当前日期完全相同时,才会显示记录。这是我的密码: public function index() { $date = date('o-m-d'); $oneWeekLater = strtotime('+1 Week'); $twoWeekLater = s

我想知道如何显示日期与本周相符的记录。例如,如果我们有从12.05到18.05的天数,并且我们在表中有值为12.05的行和值为18.05的行的记录

我试着这么做,但它并没有按我想要的那样工作。问题在于,仅当“开始”值与当前日期完全相同时,才会显示记录。这是我的密码:

public function index() {
    $date = date('o-m-d');
    $oneWeekLater = strtotime('+1 Week');
    $twoWeekLater = strtotime('+2 Week');
    $date_next = date('o-m-d', $oneWeekLater);
    $date_next_two = date('o-m-d', $twoWeekLater);
    $this->set('timetables', $this->Timetable->find('all', array(
    'conditions' => array('From' => $date_next)
    ))
    );
    $this->set('timetables_plus', $this->Timetable->find('all', array(
    'conditions' => array('From' => $date_next)
    ))
    );
    $this->set('timetables_plus_two', $this->Timetable->find('all', array(
    'conditions' => array('From' => $date_next_two)
    ))
    );
}
我的问题是,如何做到这一点?

试试这个:

$week_start = date('Y-m-d', strtotime("-1 weeks"));
$week_end = date('Y-m-d');

$conditions = array(
    "From >" => $week_start,
    "From <=" => $week_end,
);
$week\u start=date('Y-m-d',strottime(“-1周”);
$week_end=日期('Y-m-d');
$conditions=数组(
“从>”=>$week\u开始,
“从尝试以下方法:

$week_start = date('Y-m-d', strtotime("-1 weeks"));
$week_end = date('Y-m-d');

$conditions = array(
    "From >" => $week_start,
    "From <=" => $week_end,
);
$week\u start=date('Y-m-d',strottime(“-1周”);
$week_end=日期('Y-m-d');
$conditions=数组(
“从>”=>$week\u开始,
“从可能的副本到可能的副本”