typo3fluid

wrong output for format.date


I´m trying to update an old simple extension, which has a date-field (type "date" in database). Dates are saved like "2024-09-05" in the database.

In the fluid template, i have something like:

<f:format.date format="d.m.Y">{foo.startdate}</f:format.date>

I works fine (output like 05.09.2024) in TYPO3 11, but in TYPO3 12 outout is 01.01.1970 for all dates.

Has anyone an idea what to do? Thanks!


Solution

  • That solves my problem:

    1. Change fieldtype of startdate from date to int(11) unsigned DEFAULT '0' NOT NULL
    2. Convert values from date (2024-09-07) to timestamp
    3. Update TCA for that field

    like that:

    'startdate' => [
        'exclude' => true,
        'label' => 'LLL:EXT:myextension/Resources/Private/Language/locallang_db.xlf:myextension.startdate',
       'config' => [
            'type' => 'datetime',
            'default' => 0,
            'behaviour' => [
                'allowLanguageSynchronization' => true,
            ],
        ],
    ],
    

    You can use "Select UNIX_TIMESTAMP(startdate), uid FROM mytable;" to get the timestamp values, than use that data to update the values: "Update mytable SET startdate=1529186411 WHERE uid =123;". There might be a better way to do that!