date format in list labels
hi there,
would anybody know how i would format a date (timestamp) in the dca list labels?
I don't want to show unix timestamps to the poor users.
like so:
$GLOBALS['TL_DCA']['tl_xxx']['list']['label'] => array
(
'fields' => array('name', 'create_date', 'sent_date', 'club_id'),
'format' => '%s <span style="color:#b3b3b3; padding-left:3px;">(created: %s, sent: %s, Club: %s)</span>'
),
thanks in advance
Re: date format in list labels
if you set the 'flag'=> 5, 6, 7, 8, 9, 10 (any of these)
parameter and it will format automatically as datTimFormat. If you only want date, then you're out of luck. You'll have to write a custom child_record_callback (mode=4) or label_callback (other modes). In this label callback you can then use the $row['date'] values and format them accordingly, e.g.
[attachment=0:3gon65gc]labelcallback.jpg[/attachment:3gon65gc]
Code:
public function listItems($arrRow)
{
$start = $this->parseDate((strlen($GLOBALS['TL_CONFIG']['dateLongFormat']) ? $GLOBALS['TL_CONFIG']['dateLongFormat'] : 'j F Y'), $arrRow['start']);
$stop = $this->parseDate((strlen($GLOBALS['TL_CONFIG']['dateLongFormat']) ? $GLOBALS['TL_CONFIG']['dateLongFormat'] : 'j F Y'), $arrRow['stop']);
return '
<div class="">' . $arrRow['title'] . ': '. $start . ' - ' . $stop . '</div>';
}
Re: date format in list labels
you again! ;-)
bingo! label_callback was the key!
thanks, works like a charm.