1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Server-side datatable implementation: how to read the date in dd/mm/yy format from the...

Discussão em 'Outras Linguagens' iniciado por el_codigo_me_encanta, Novembro 7, 2024 às 19:43.

  1. As the title suggests, I am implementing server-side datatable.

    I am having a problem with the global search to read birthDate in dd/mm/yy format.

    I can only read the date in y-m-d format (i.e. the default date of the db).

    This is my code:


    // get data from user_dummies table
    $query = DB::table('user_dummies')->select('*');

    // Global Search
    $search = $request->search;
    $query = $query->where(function ($query) use ($search) {
    $query->orWhere('firstName', 'like', "%" . $search . "%");
    $query->orWhere('lastName', 'like', "%" . $search . "%");
    $query->orWhere('age', 'like', "%" . $search . "%");
    $query->orWhere('birthDate', 'like', "%" . $search . "%");
    $query->orWhere('role', 'like', "%" . $search . "%");
    });

    I tried to write the code corresponding to the birthDate put below but I get an error from datatable,

    i.e. DataTables warning: table id=datatable - Ajax error.


    $query->orWhere(date('d/m/y',strtotime('birthDate')), 'like', "%" . $search . "%");

    Can someone tell me how to do this?

    Continue reading...

Compartilhe esta Página