2

I use the (server-side processing) pipelining data feature from DataTables to reduce Ajax calls for paging.

$columns = array(
array( 'db' => 'order_number', 'dt' => 0 ),
array( 'db' => 'customer',  'dt' => 1 ),
array( 'db' => 'commission',   'dt' =>  2 ),
array(
    'db'        => 'timestamp_created',
    'dt'        => '3',
    'formatter' => ???
)

);

My question is how can i configure the formatter? For example i have a timestamp so i want to format this timestamp from my database into a more user-friendly-format. This isn´t a problem, but i can not write a normal php function - which would do this for me. If i do it, i get an error. So can anyone help me out and is able to give me a example in how to use this formatter?

Edited:

The answer is not that i didn´t get it by myself in a correct way, the answer is my php version was too old and so the formatter didn´t worked as it should be working. You need at least PHP version 5.3!

Maybe this will help somebody in the future.

1

1 Answer 1

1
$columns = array(
array( 'db' => 'order_number', 'dt' => 0 ),
array( 'db' => 'customer',  'dt' => 1 ),
array( 'db' => 'commission',   'dt' =>  2 ),
array(
    'db'        => 'timestamp_created',
    'dt'        => '3',
    'formatter' => function( $d, $row ) {
                    return date( 'd-m-Y', strtotime($d));
                }
)
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.