search

Home  >  Q&A  >  body text

How to use laravel between

For example
To implement data query within a month
Then you should use between to calculate the time. How does laravel's ORM implement the between operation

$start = '开始时间';
$end = '结束时间';
$map['time'] = array('between' , array($start , $end));
User::where($map)->get();

The above code is invalid

怪我咯怪我咯2750 days ago873

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 16:49:21

    User::whereBetween('created_at', [$start, $end]);
    
    //or
    
    User::where('created_at', '>=', $start)->where('created_at', '<=', $end);

    reply
    0
  • 高洛峰

    高洛峰2017-05-16 16:49:21

    $obj=Condition 1;
    $obg=$obj->where();
    $obg=$obj->where();
    Just use this method

    reply
    0
  • Cancelreply