I would like to retrieve articles that are within 1 year from the today’s date. Basically, I would like to split the article section of my site into new articles (within 1 year) and archived articles (older than 1 year). How do I change the following statement to make sure this happens?
$articles = $this->Article->find(
'all',
array(
'fields' => array(
'Article.title',
'Article.body',
'Article.slug',
'Article.id',
'Article.image',
'Article.created'
),
'order' => 'Article.created DESC',
'conditions' => array(
'Article.created >' => //What do I need to add here
)
)
);
I will do the same thing for archived articles but with different condition:
$archived_articles = $this->Article->find(
'all',
array(
'fields' => array(
'Article.title',
'Article.body',
'Article.slug',
'Article.id',
'Article.image',
'Article.created'
),
'order' => 'Article.created DESC',
'conditions' => array(
'Article.created <' => //What do I need to add here
)
)
);
Thank you,
1 Answer