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

Stephan Schuler Stephan.Schuler at netlogix.de
Mon Jan 12 17:40:30 CET 2015


Well, I didn't expect anybody to use the native datetime mechanism except those dbal guys :)

If your mysql column is "datetime", then using \DateTime objects without ->format() should result in "Y-m-d H:i:s" instead of a unix timestamp.
So 2. shows some configuration error.

Did you miss the "dbType = 'datetime'" configuration?
http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Common/Index.html#dbtype

Where does this native datetime colum come from? Did you introduce it manually or is this the result of the current extension builder?

The difference between TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface and TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface still confuses me a little :).

The Generic\Backend (which implements the Generic\BackendInterface) is aware of the dbType configuration.
The Generic\Storage\Typo3DbBackend (which implements the Generic\Storage\BackendInterface) is *not* aware of the dbType configuration.

Both have a *::getPlainValue() method where the dbType aware magic happens ... or not.

Could you quickly break point both *::getPlainValue() methods and show which of those is used?

Regards,



Stephan Schuler
Web-Entwickler | netlogix Media

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Web: media.netlogix.de




netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Web: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Jan Kornblum
Gesendet: Montag, 12. Januar 2015 16:55
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] How to compare a DateTime object correctly inanExtbase query?

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


_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list