Search code examples
typo3typoscript

How to format a date string like '2018-08-31'


I've got a date-string like '2018-08-31' from tt_content and want to convert it like this: '31 August 2018' - how do I get this to work?

I've tried this:

10 = TEXT
10 {
    wrap = |
    data.field = tx_mask_cnt_news_item_date  // field in tt_content, is '2018-08-31'
    strftime = %e %B %Y
}

But this puts out the current date (in the desired format). Can somebody give me a hint?


Solution

  • I've found a solution: With strtotime = 1 the string will be converted into a timestamp and then strftime will work as expected:

    10 = TEXT
    10 {
        wrap = |
        field = tx_mask_cnt_news_item_date  // field in tt_content, is '2018-08-31'
        strtotime = 1
        strftime = %e %B %Y
    }