Structures_DataGrid_Column::format() – Choose a format preset


require_once 'Structures/DataGrid/Column.php';

void Structures_DataGrid_Column::format ( $type , mixed $type,... )


EXPERIMENTAL: the behaviour of this method may change in future releases.

This method allows to associate an "automatic" predefined formatter to the column, for common needs as formatting dates, numbers, ...

The currently supported predefined formatters are :

  • dateFromTimestamp: format a UNIX timestamp according to the date()-like format string passed as second argument

  • dateFromMysql : format a MySQL DATE, DATETIME, or TIMESTAMP MySQL according to the date() like format string passed as second argument

  • number: format a number, according to the same optional 2nd, 3rd and 4th arguments that the number_format() PHP function accepts.

  • printf: format using the printf expression passed as 2nd argument.

  • printfURL: url-encode and format using the printf expression passed as 2nd argument



mixed $type,...

Predefined formatter name, followed by formatter-specific parameters


throws no exceptions thrown


Common formats


// Format UNIX timestamps as english dates:

// Format MySQL DATE, DATETIME or TIMESTAMP strings as french dates:

// Format numbers with 3 decimals and no thousands separator:

// Format numbers with 2 decimals:

// Format using a printf expression:
$column->format('printf''Number of potatoes: %d');

// Format an HTML link using a printf expression with url-encoding:
$column->format('printfURL''<a href="edit.php?key=%s">Edit</a>'); 



This function can not be called statically.

Constructor (Previous) Formatter (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.