Search code examples
typo3typo3-8.x

format date in typoscript in TYPO3 8


I want to format the date with typoscript:

10 = CONTENT
10 {
    table = tx_beratungstermine_domain_model_termine
    select.pidInList = 456
    renderObj = COA
    renderObj {
        10 = TEXT
        10.field = datetime
        10.strftime = %A den %d.%m.%Y

        20 = TEXT
        20.value = |

        30 = TEXT
        30.field = uid

        stdWrap.wrap = |[\n]
    }
}

It should work but i get

Donnerstag den 01.01.1970

Without the line

10.strftime = %A den %d.%m.%Y

I get the correct date but in false format.

What is wrong with my code?

Thank!


Solution

  • OK, I found the reason. The problem was the definition of the datetime field in the database. typoscript date does not work with a sql field of type datetime. It only works with field type int. I had to change the sql to:

    datetime int(11) DEFAULT '0' NOT NULL,
    

    and the TCA to

    'config' => [
        'type' => 'input',
        'size' => 16,
        'eval' => 'datetime',
        ],
    ],