Nice module, I'm just getting to grips with it now. I've got my table displaying the results I want but I'd like to work out how to format some of the results. I have a column which is displaying a field's timestamp in the Date API 2 format which is something like: 2008-03-04T00:00:00

How do I format this to something different? I'm guessing I place a callback when defining the array for that particular column so something like this:

  	'columns' => array(
  		array(
    		'col' => 'field_ride_reference_value',
    		'label' => 'Route or ride reference',
    		'sortable' => TRUE,
    		'searchable' => TRUE,
    		'help' => 'Your route reference',
   		),
   		array(
    		'col' => 'field_ride_date_value',
    		'label' => 'Date',
			'sortable' => TRUE,
			'searchable' => TRUE,
			'default_sort' => 'desc',
			'help' => 'The date of the ride',
			'callback' => 'ajaxtable_col_date_myexample',
			)

Unfortunately I'm not sure what I should be doing in my function to format and return the value. Anyone able to help me out?

Comments

tanc’s picture

Status: Active » Fixed

I managed to figure this out. Here is my solution for anyone that needs it:

	function ajaxtable_col_date_myexample($col,$value,$row) {
	$converted = date_convert($row['field_ride_date_value'],DATE_ISO,DATE_UNIX);
	$ridetime = date('d M y',$converted);
	return ($ridetime);
}

The function above is the callback function mentioned in my first post. This uses the date API to convert from the MySQL datestamp into the Unix timestamp and then format it with PHP's date function and finally return the formatted value.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.