[TYPO3-dev] Date format in Extbase

Felipe Rodriguez felipe at netnnet.de
Tue Feb 23 15:06:36 CET 2016


First of all thanks to the Typo3 Community for the latest realeases!

I have the following problem. In an extension I define an object with a property 'date' with the date format (from the Extension Builder). This is implemented in the following way:
* In the model the property is defined with the @var \DateTime annotation
* In the database it is defined with the date type, which saves the dates in the YYYY-MM-DD format
* In the TCA it has 'type' => 'input', 'dbType' => 'date'

The problem comes when, in the controller I need to find one object by date. I use the 'magic' method findByDate but it doesn't find the object. For example, in the database there is an object with the date property set to '2016-02-17'. In the controller I create a DateTime object with exactly the same timestamp and pass it to the findByDate method of the repository. But the method returns an empty result.

As far as I have investigated the problem occurs during the lazy loading when the Typo3DbBackend do the resolveParameterPlaceholders(). It calls the getPlainValue method of the DataMapper with the second argument set to null. Then, in the getPlainValue method, when the placeholder is resolved it looks for some columnMap configuration which was hardcoded to null (for the reason given above) and defaults to the unix timestamp format which is 1455667200. Later, in the sql statement it uses the condition 'where date = 1455667200' which will never get the result because it is saved in the database in the YYYY-MM-DD format. 

What would be the best way to solve this issue? I know that everything would be solved if I use full timestamps in the database but then I would think that Extbase does not support the date type in the database. Is this true?

Regards,
Felipe



More information about the TYPO3-dev mailing list