点亮的数据表中的日期回调函数不起作用

时间:2015-08-08 19:48:38

标签: codeigniter datatables

我使用点燃数据表库进行codeigniter 这是我的代码:

function datatable()
    {
        $this->datatables->select('id,name,created')
            ->unset_column('id')
            ->edit_column('created', '$1',date('Y-m-d H:i:s','created'))
            ->from('categories');

        echo $this->datatables->generate();

    }

创建的是unix时间戳,我想在表中显示日期。 但是当我使用像这样的回调函数或在帮助器中它不起作用。 php警告:

A PHP Error was encountered

Severity: Warning

Message: date() expects parameter 2 to be long, string given

Filename: controllers/categories.php

Line Number: 22

created是数据库中的unix时间戳值。当我将它传递给日期函数时,数据库值不会传递给日期函数。当我var_dump它显示$ 1而不是数据库的实际值。在其他功能,它工作正常。但在日期函数返回错误。

1 个答案:

答案 0 :(得分:0)

使用此

   $this->datatables->select('id,name,created')
        ->unset_column('id')
        ->edit_column('created', '$1',timestamp('Y-m-d H:i:s'))
        ->from('categories');

Timestamp Manual