Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Server-side: formatter function

$
0
0

Hello all,
The goal of my current script is to get server-side processing working with "custom" variables, i.e., variables that I need to modify before being passed to the table.
For example, in the code below, I am trying to convert a value in milliseconds into minutes:seconds:milliseconds in the server side script. Does anyone know how I can use more than two variables in the "return"?

Currently, the codereturn number_format($minutes, $seconds, $milliseconds); does not return any value while return number_format($minutes, $seconds); does work. I assume it may have something to do with 'formatter' => function( $d, $row) only passing two variables instead of the three I need?

The full script is below. Thank you for your assistance!

`$columns = array(
array( 'db' => 'ID', 'dt' => 0 ),
array(
'db' => 'alternateEventDurationInMilliseconds',
'dt' => 1,
'formatter' => function( $d, $row) {

$milliseconds = $d;
$time = $milliseconds / 1000;
$days = floor($time / (246060));
$hours = floor(($time - ($days246060)) / (6060));
$minutes = floor(($time - ($days246060)-($hours60*60)) / 60);

$seconds = ($time - ($days246060) - ($hours6060) - ($minutes60)) % 60;

        return number_format($minutes, $seconds, $milliseconds);
    }

),`


Viewing all articles
Browse latest Browse all 2364

Trending Articles