You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pierre Germain edited this page Aug 14, 2019
·
3 revisions
Entity Query with dates
Get past ids
$field = 'field_name';
$now = date('Y-m-d', time());
$start = date('Y-m-d',strtotime($now.'-'.$days.' days'));
// Get past ids using entityQuery.
$ids = \Drupal::entityQuery('entity_type')
->condition($field, $now, '<=')
->execute();
// Get ids for a specific date
$ids = \Drupal::entityQuery('commerce_product_variation')
->condition($field, $now)
->execute();
// Get ids from a range of dates
$ids = \Drupal::entityQuery('commerce_product_variation')
->condition($field, $now, '<=')
->condition($field, $start, '>=')
->execute();