Skip to content

DateTimeAttribute criterion

The DateTimeAttribute Search Criterion searches for products by value of a specified attribute, based on the date and time attribute type.

Arguments

  • identifier - attribute's identifier (string)
  • value - searched value (DateTimeImmutable)

Operators

The following operators are supported:

Example

PHP

The following example lists all products for which the event_date attribute has value equal to 2025-07-06.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?php declare(strict_types=1);

use DateTimeImmutable;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery;
use Ibexa\Contracts\ProductCatalogDateTimeAttribute\Search\Criterion\DateTimeAttribute;

$query = new ProductQuery();
$filter = new DateTimeAttribute('event_date', new DateTimeImmutable('2025-07-06'));
$filter->setOperator(FieldValueCriterion::COMPARISON_EQ);
$query->setFilter($filter);
/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService */
$results = $productService->findProducts($query);