Laravel在日期之间

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 = '2016/01/28';
$to = '2016/01/28';
$id = 1;

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

Can i recommend you using Carbon then you can do something like this:

In your model

public function getDaysUntilDeadlineAttribute()
{   
    return Carbon\Carbon::now()->startOfDay()->diffInDays($this->outdate_time, false); // if you are past your deadline, the value returned will be negative.  
}

And then in your view:

$model->days_until_deadline

Remeber to include use Carbon; at the top

In your code you are comparing the dates with wrong format.

Your dates are as follows

$from = '2016/01/28';
$to = '2016/01/28';

The date formats in db are

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

Now simply just change the $from and $to date formats to

 $from = '2016-01-28 12:14:07';
 $to = '2016-01-28 09:03:23';

now you can write the query with above values.

If any rows matched those will be displayed.