Results 1 to 3 of 3

Thread: date format in list labels

  1. #1
    New user
    Join Date
    07-26-10.
    Posts
    14

    Default 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

  2. #2
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default 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>';
    	}

  3. #3
    New user
    Join Date
    07-26-10.
    Posts
    14

    Default Re: date format in list labels

    you again! ;-)

    bingo! label_callback was the key!

    thanks, works like a charm.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •