Datatable returns NULL datetime values as 1969-12-31

Datatable returns NULL datetime values as 1969-12-31

webpointzwebpointz Posts: 126Questions: 30Answers: 4

Hoping someone can help me.

I have a page with an editor table at the top, and a datatable on the bottom.

Both show the same fields, including a date field.

In the datatable field, it is displaying NULL values from the database as 1969-12-31.

Does anyone know how I can handle the NULL values to display as nothing with the following server processing code:

array( 'db' => 'expirydate',            
        'dt' => 3,
        'formatter' => function( $d, $row ) {
            return date( 'Y-m-d', strtotime($d));
        }

This question has an accepted answers - jump to answer

Answers

  • webpointzwebpointz Posts: 126Questions: 30Answers: 4
    Answer ✓

    Found a solution that appears to work. Here is the code I'm using:

        array(
            'db'        => 'expirydate',                
            'dt'        => 1,
            'formatter' => function( $d, $row ) {
                if(strtotime($d)!= NULL){
                   return date( 'Y-m-d', strtotime($d));
                }else{
                   return '';
                }      
            }
        )
    
    
This discussion has been closed.