Bug #92900
Updated by Imko Schumacher over 3 years ago
The datetime input @00:00 01-01-1970@ (special value - start of unix epoch, timestamp 0) gets saved as default value @0000-00-00 00:00:00@.
h2. Prerequisite
- testet on master(9ded7c21f126627b090b4f13715f03d3c57ebe30), 10.4.9 and seems to be present in older versions
TCA configuration:
<pre><code class="php">
'columns' => [
'mydatetime' => [
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'dbType' => 'datetime',
'eval' => 'datetime,null',
],
],
],
</code></pre>
h2. Steps to reproduce the problem
* Input the following values in the backend record editor
* @ 00:00 01-01-1970@
* Save the form
h2. Actual results
Database:
* @0000-00-00 00:00:00@
(Default value for datetime)
h2. Expected results:
Database:
* @1970-01-01 00:00:00@
h2. Additional notes
* There was already some discussion on https://review.typo3.org/c/Packages/TYPO3.CMS/+/66670 , but got outsourced to here
* Also influences time inputs (e.g. 00:00), however works out in the end
* Problem location: *DataHandler -> checkValueForInput*
* The input gets converted to a tiemstamp for the "sake of checks".
In this case, the resulting timestamp is @0@ and interpreted as false in the following checks (both need to be fixed)
><pre><code class="php">
if (isset($tcaFieldConf['dbType']) && isset($res['value']) && !$res['value']) {
// set the value to null if we have an empty value for a native field
$res['value'] = null;
}
</code></pre>
> <pre><code class="php">
$res['value'] = $res['value'] ? gmdate($format, $res['value']) : $emptyValue;
</code></pre>