如何格式化日期字符串,例如“ 2018-08-31”

时间:2019-03-26 11:32:20

标签: typo3 typoscript

我从tt_content中获得了一个日期字符串,例如“ 2018-08-31”,并希望将其转换为:“ 2018年8月31日”-如何使它工作?

我已经尝试过了:

layout_height

但这会显示当前日期(采用所需格式)。有人可以给我提示吗?

2 个答案:

答案 0 :(得分:1)

Try this:

10 = TEXT
10 {
    wrap = |
    field = tx_mask_cnt_news_item_date
    strftime = %e %B %Y
}

data.field = tx_mask_cnt_news_item_date will set the content of tx_mask_cnt_news_item_date as the value for data, which will result in nothing. field directly in the TEXT object will set the content of tx_mask_cnt_news_item_date as the value of the TEXT object, which will then be passed through strftime.

答案 1 :(得分:1)

我找到了一个解决方案:使用 imageLabel.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { updateBrush(); point.add(event.getPoint()); imageLabel.updatePointList(point); repaint(); } }); imageLabel.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent event) { updateBrush(); point.add(event.getPoint()); imageLabel.updatePointList(point); repaint(); } }); 字符串将被转换为时间戳,然后strtotime = 1将按预期工作:

strftime