Project

General

Profile

Actions

Bug #79448

closed

Epic #77562: Misbehaviors with datetime values and timezones

Handling dates in the very past inside T3-Backend

Added by Ralle Büchnitz about 7 years ago. Updated 9 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2017-01-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

I tried to store a date around 01.01.1800 in T3-Backend.

I wrote an extension but saving fails each time - as the date is not stored correctly.

I can't even say how T3 determines/converts the date. As the system stores something around 1936. Seems like some sort of converting error in T3-Backend. Same with dates in the very future.

If i set the 'date' field directly in the database to the correct date it won't be displayed at all.

Here are some additional informations:

\ext_tables.sql
geboren_am date DEFAULT '0000-00-00',

Configuration\TCA\mymodel.php
'geboren_am' => array(
'exclude' => 1,
'label' => geboren_am',
'config' => array(
'dbType' => 'date',
'type' => 'input',
'size' => 13,
'max' => 20,
'eval' => 'date',
'checkbox' => 0,
'default' => '0000-00-00'
),
),


Related issues 3 (1 open2 closed)

Related to TYPO3 Core - Bug #69287: Can't enter years before 1902 in date-fieldsClosed2015-08-24

Actions
Related to TYPO3 Core - Bug #37244: TCA date evaluation for dates lower 01-01-1970 failsClosed2012-05-17

Actions
Related to TYPO3 Core - Bug #91508: It is not possible to save "negative" dates, e.g. a year before jesus christus with date inputsNew2020-05-27

Actions
Actions #1

Updated by Ralle Büchnitz about 7 years ago

Any news on this issue?

Actions #2

Updated by Riccardo De Contardi almost 7 years ago

  • Category set to FormEngine aka TCEforms

I add here the comment from #69287 to keep track of it:

To describe the problem a bit more:

the 1970-Problem with dates usually is JavaScript-related.
The datepicker from ExtJS (implemented in TYPO3, at least 6.2) can handle dates back to year 0.
MySQL-datetime can handle dates starting with year 1000. This general option was implemented by Xavier already.
The Datetime-functions of AdoDB can handle years back to year 0, with adjustments probably further back too.
Some databases can handle dates that go further back than 0, i.e. PgSQL can handle approximative -4500
Some PHP-Functions might limit the handling of dates too.
So the problem involves JavaScript, Database and PHP depending on how far you want to be able to go back.
I think a really cool approach would be to enable TYPO3 to take dates older than 0.
I planned working on it but never found the time yet and in the moment I never see any time-window in nearer future.

Actions #3

Updated by Mona Muzaffar almost 7 years ago

  • Related to Epic #80852: Datetime handling in backend added
Actions #4

Updated by David Bruchmann almost 7 years ago

To understand what's happening it might be helpful to know the history how the current date-handling was first created:
http://xavier.perseguers.ch/en/tutorials/typo3/articles/native-date-type.html

It might be completely different now especially because of refactoring inside TYPO3.

Actions #5

Updated by Christian Fries almost 7 years ago

This problem still exists in TYPO3 8. And on top of that: If you try to save an empty date (empty field), you get an error:

1: These fields of record 2 in table "tx_extensionname_domain_model_person" have not been saved correctly: date_of_birth! The values might have changed due to type casting of the database.
Actions #6

Updated by David Bruchmann almost 7 years ago

Christian,

I dare to say, the error is an issue with your extension. Probably it can be fixed by changes in database or TCA.
Have a look at the definitions in \ext_tables.sql and Configuration\TCA\mymodel.php above posted by Ralle Büchnitz, especially at 'default' and "geboren_am date DEFAULT '0000-00-00'".

Actions #7

Updated by Christian Fries almost 7 years ago

Hi David, I dare to say that's not true. The exact above configuration will not allow you to save a record (form engine, not extbase) with an empty "geboren_am" field in TYPO3 8.7.1.
If you don't belive me, check out the well known extension styleguide. When you try to save the demo record with no date in inputdatetime_2 (which has the same configuration we talk about here, see TCA and sql), you'll get the same error I get in my extension.

Actions #8

Updated by Anonymous almost 7 years ago

I can confirm the problem of Christian.
Saving an empty date gives always the "The values might have changed due to type casting of the database." error.

It looks like the problem is some value casting, at least InputDateTimeElement.php always has $itemValue set to 0 instead of '0000-00-00' (which explains the error message).

Actions #9

Updated by Riccardo De Contardi almost 7 years ago

  • Parent task set to #77562
Actions #10

Updated by Riccardo De Contardi almost 7 years ago

  • Related to deleted (Epic #80852: Datetime handling in backend)
Actions #11

Updated by Christian Fries over 6 years ago

Couldn't be reproduced in current master anymore.

Actions #12

Updated by Riccardo De Contardi about 6 years ago

I think it is still present in 8.7.9 - It is not possible to save a date prior to 01-01-1970 for example in the "start date" of fe_users. The error is still:

1: These fields of record 1 in table "fe_users" have not been saved correctly: starttime! The values might have changed due to type casting of the database.
Actions #13

Updated by Daniel Siepmann over 3 years ago

  • Related to Bug #91508: It is not possible to save "negative" dates, e.g. a year before jesus christus with date inputs added
Actions #14

Updated by Benni Mack 9 months ago

  • Status changed from New to Closed

we've finally fixed this in TYPO3 v12. With type=datetime (and even better with dbType=date and format=date) this works just fine, tested this just now. https://docs.typo3.org/m/typo3/reference-tca/12.4/en-us/ColumnsConfig/Type/Datetime/Index.html

If you feel this is still an issue in TYPO3 v12, let me know, and I will-re-open the issue.

Actions

Also available in: Atom PDF