Skip to content

Instantly share code, notes, and snippets.

@alexdrupal
Last active December 28, 2015 16:19
Show Gist options
  • Save alexdrupal/7528513 to your computer and use it in GitHub Desktop.
Save alexdrupal/7528513 to your computer and use it in GitHub Desktop.
Filter Magento collection by date
<?php
$collection->addFieldToFilter('start_date',
array(
array('to' => Mage::getModel('core/date')->gmtDate('Y-m-d')),
array('start_date', 'null' => '')
)
);
$collection->addFieldToFilter('end_date',
array(
array('gteq' => Mage::getModel('core/date')->gmtDate('Y-m-d')),
array('end_date', 'null' => '')
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment