Issue Bug Closed

#100649Extbase DataMapper doesn't respect datetime when 0 or 0000-00-00 or 0000-00-00 00:00:00 or 00:00:00

Sebastien Convers 04/18/23, 07:09 updated 12/02/25, 14:33

Description

When using TCA to set an input to datetime or time, like in the documentation (https://docs.typo3.org/m/typo3/reference-tca/11.5/en-us/ColumnsConfig/Type/Input/DateTime/Properties/DbType.html#time-picker-stored-in-a-datetime-field)

'synced_at' => [
   'config' => [
      'type' => 'input',
      'dbType' => 'time',
      'eval' => 'time,null',
   ],
],

The “core” part is working fine, you can set your field to null or midnight (00:00:00)

But then this line in extbase (https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php#L315) change it to null no matter what, so you cannot know if your time property is not set (null) or midnight (00:00:00)

// Invalid values are converted to NULL
if (empty($value) || $value === '0000-00-00' || $value === '0000-00-00 00:00:00' || $value === '00:00:00') {
    return null;
}

A workaround is to change the type of your property to string, and use an extra getter method to make the conversion yourself.

Reviews 2