This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » Criterion Field datetime

Criterion Field datetime

Criterion Field datetime

Tuesday 08 July 2014 3:47:40 pm - 9 replies


i'm trying to implement a very simple thing, to add a criterion base on date and time attribute

$now = time();
$criteria[] = new Criterion\Field( 'start_date', Criterion\Operator::LTE, $now );

Is it the right criterion definition or am i missing something ?

Tuesday 08 July 2014 5:49:37 pm

Hello Joël,

Here is a fully working example:

$query->criterion = new Criterion\LogicalAnd(
        new Criterion\Visibility(Criterion\Visibility::VISIBLE),
        new Criterion\ParentLocationId($this->locationId),
        new Criterion\ContentTypeIdentifier(['my_contentTypeIdentifier']),
        new Criterion\Field('end_date', Criterion\Operator::LT, time())

Modified on Tuesday 08 July 2014 5:51:53 pm by Julien Garin

Wednesday 09 July 2014 10:44:16 am

Thanks Julien for your reply , but that's what i did except operator LTE 

Wednesday 09 July 2014 10:52:10 am

Did it work with LT but not LTE?

Wednesday 09 July 2014 4:35:10 pm

So i tried many options nothing works...

to resume 

an attribut start_date (date and time)

this is the query i use :

$query = new Query();        
$query->filter = new Criterion\LogicalAnd(            
                new Criterion\Visibility(Criterion\Visibility::VISIBLE),                
                new Criterion\Subtree( $location->pathString ),                
                new Criterion\ContentTypeIdentifier(array('contest')),                
                new Criterion\Field('start_date', Criterion\Operator::LT, time())            
$query->sortClauses = array(new SortClause\Field('contest', 'start_date', Query::SORT_DESC, $languages[0]) );
$query->limit = 2;

I get results without (and i suppose to get result in any case) :

 new Criterion\Field('start_date', Criterion\Operator::GT, time())

I changed Operator by LTE , LT, GTE => nothing

Modified on Wednesday 09 July 2014 4:36:53 pm by Joël LEGER

Wednesday 09 July 2014 6:11:46 pm

And trying with 


instead of



Modified on Wednesday 09 July 2014 6:13:35 pm by Julien Garin

Thursday 10 July 2014 12:14:04 am


Thursday 10 July 2014 12:47:46 am

Since you have a subtree limitation, I suggest using a LocationQuery instead of a query and

$searchResult = $searchService->findLocations( $query );

Modified on Thursday 10 July 2014 12:48:44 am by Jérôme Gamez

Thursday 10 July 2014 12:51:51 am

Also Petar Španja has written a great article about content fetching: Fetching content in eZ Publish 5 using Search service.

Friday 07 November 2014 3:14:45 pm


I had the some problem today... In my case I had to set the field to "searchable" in backend. After that all the criterias worked for me.



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from