I'm trying to get elements in a section created on a specific date. How do I do that?

This is what I've been trying with:

$criteria               = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section  = 'sectionHandle';
$criteria->postDate     = '2014-11-04';

1 Answer 1


Something like this should work:

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section  = 'sectionHandle';
$criteria->postDate = array('and', '> 2014-11-03 23:59:59', '< 2014-11-05 00:00:00');
$results = $criteria->find();
  • This works great Brad. Is there any way I can make it just by the date and not include the time? I tried yii-syntax with postDate = ['IN', '2014-11-04'] but that got me a "Fatal error: Call to a member function getTimestamp() on a non-object in /craft/app/helpers/DbHelper.php on line 597". Any ideas? Mar 19, 2015 at 17:51
  • Nothing I can think of...
    – Brad Bell
    Mar 19, 2015 at 17:56
  • Is there another way you would recommend me fetching elements from a section posted at a specific date using Craft build in API functions? Mar 19, 2015 at 18:00
  • Not without directly querying the database.
    – Brad Bell
    Mar 19, 2015 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.