This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » eZ Publish 5 Platform » Time-Offset on search

Time-Offset on search

Time-Offset on search

Thursday 18 June 2015 5:59:22 pm - 2 replies

I have an interesting issue regarding filtering content.

Currently I try to use the search-service to find content which has two ezdatetime-attributes which surround a given timestamp.
So my filter is like "start" < currenttime < "end".

Anyway for some reason the timestamp stored in the field is off by +2 hours which is the timezone I live in.
First i thought, well you have to set the timezone in php.ini but that was not the issue.

What i found to far is, that the legacy-stack which I'm writing the content with using the backend, somehow writes the correct date-time (gmt) as timestamp and the time-function in php returns the same date-time with a timestamp for GMT+2:00 DST

The solution to just add the 2 hours does not seem legit.

            $criterion[] = new LogicalAnd(                array(                    new Criterion\ContentTypeIdentifier($identifier),                    new LogicalOr(                        array(                            new LogicalAnd(                                array(                                    new Field($config['start_attribute'], Operator::GT, $this->currentTime->getTimestamp()),                                    new LogicalNot(                                        new Field($config['start_attribute'], Operator::EQ, 0)                                    )                                )                            ),                            new LogicalAnd(                                array(                                    new Field($config['end_attribute'], Operator::LT, $this->currentTime->getTimestamp()),                                    new LogicalNot(                                        new Field($config['end_attribute'], Operator::EQ, 0)                                    )                                )                            )                        )                    )                )            );

Thanks for any help. It's kind of messing up my head by now.^^

Modified on Thursday 18 June 2015 6:04:13 pm by Steve Konrad

Saturday 20 June 2015 2:40:08 pm

Hi Steve,

Hope you are ok!

I'm not quite sure where the issue might be here, ideally datetime should probably store in GMT and keep track of timezone data separately. But besides that I suspect this being a bit different in new stack and old stack.


Best wishes,

Saturday 20 June 2015 5:02:01 pm

Hi Steve,

if I got you right, you found that the DateAndTime value is stored incorrectly when using new stack? If that is the case, can you show how the field value is set?

If you verified that the timestamp values are stored correctly through Legacy Stack and the problem is still present, I would assume that the problem comes form the query, as there is no DateTime manipulation in the Legacy Search Engine. In this case it simply compares given integer number representing the timestamp with the integer field column in the database table containing the timestamp value.

In that case, could you show how "$this->currentTime" is initialized? It might be the place where your timezone gets in the picture.

BTW, I would suggest you use BETWEEN operator if possible, the query will be much simpler and probably more efficient.




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

36 542 Users on board!

Forums menu

Proudly Developed with from