[TYPO3-mvc] How to compare a DateTime object correctly inanExtbase query?

Jan Kornblum jan.kornblum at gmx.de
Mon Jan 12 16:55:08 CET 2015


Hi Stephan,

thank a lot for your time.

In TYPO3 Backend, date_published is "5:00 6-1-2015" and in the Database 
it is "2015-01-06 05:00:00", too. Everything later (Extbase, Fluid) it 
is 6:00 instead of 5:00.

> 2: Using \DateTime is supposed to work
-> WHERE xyz.date_published < 1420520400
-> No result at all

> 3: You should be able to use ->format('U') because integers are used plain
-> WHERE xyz.date_published < '1420520400'
-> No result at all

> 4: format('Y-m-d H:i:s')
-> WHERE xyz.date_published < '2015-01-06 06:00:00'
-> Always the current record (due to the 1 hour difference)

> 5: format('Y-m-d')
-> WHERE xyz.date_published < '2015-01-06'
-> Next record

> Is your $datePublished property annotated as "@var \DateTime"? I 
Yes, of course! And the database column is "datetime", too.

Where are the different timezones caused and how can i prevent them?

Regards, Jan




More information about the TYPO3-project-typo3v4mvc mailing list