jeudi 28 janvier 2016

Laravel Where Between Dates

I have a table which gathers simple datetime in and datetime out for a user.

I'm using laravel to output the rows where indate_time is between specific date range.

From Date: 2016/01/28
To Date: 2016/01/28

Sample entry in my table

ID | indate_time          | outdate_time
1  | 2016-01-28 21:22:49  | 2016-01-28 21:46:05

At the moment Im getting no response here's my laravel query

$from = new \DateTime('now');
$to = new \DateTime('now');
$id = 1;

        $attendance = DB::table('attendances')
        ->whereBetween('indate_time', array($from, $to))->where('id', $id)->orderBy('indate_time', 'desc')
        ->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire