Laravel 查询生成器 - 日期查询无效

Laravel Query Builder - Query on Date Not Working

我在 Laravel 查询生成器中有这样的查询-

    $baseQuery  =   DB::table(  'project');
    //$startDate="2015-09-02" - This format
    //$endtDate="2014-08-02" - This format
    if(!empty($startDate))
        $baseQuery  =   $baseQuery->where('project.completion_date', '>', $startDate);
    if(!empty($endData))
        $baseQuery  =   $baseQuery->where('project.completion_date', '<', $endData);

试试这个

$startDate = empty($startDate) ? '1970-01-01' : $startDate;
$endDate = empty($endDate) ? '2038-01-01' : $endDate;

DB::table('project')
    ->whereBetween('completion_date', [$startDate, $endDate])
    ->get();