Issue Bug Closed

#62660Copying Date- and Datetime-Fields

Christian Chabek 11/03/14, 20:20 updated 10/17/17, 23:31

Description

A Field is defined as datetime in the TCA:

'start' => array(
  // ...
  'config' => array(
    'dbType' => 'datetime',
     // ...
  ),
),

The value gets correctly written to the database.
But when copying an entity in the backend and so copying the field, it shows something strange like “0:33 01-01-1970”.

I’ve tracked this down to here:

// TYPO3\CMS\Core\DataHandling\DataHandler, Line 950
$incomingFieldArray[$column] = $incomingFieldArray[$column] ? gmdate($format, $incomingFieldArray[$column]) : $emptyValue;

Typo3 tries to format the already correctly formatted date-string.
The solution in my case was this check:

if (is_numeric($incomingFieldArray[$column])) {
  $incomingFieldArray[$column] = $incomingFieldArray[$column] ? gmdate($format, $incomingFieldArray[$column]) : $emptyValue;
}

Reviews 3