如何获取指定日期范围内的值?
how to get the values of specified date range?
我正在尝试从 table 中检索今天的值,在我的 table 中我有 created_at 列,这是插入行时自动分配的时间戳。我还有一个 send_at 列,我在其中手动插入日期时间,当我查询 send_at 范围时它可以工作,但是当我查询 created_at 列时,我什么也得不到。
$campaigns = SmsCampaign::whereBetween('created_at', array('2017-03-20 12:00:00','2017-03-20 23:59:00'))->paginate(10);
return view('sms_campaign.smscampaign')->with('campaigns', $campaigns);
型号:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SmsCampaign extends Model
{
protected $table = 'sms_campaign';
protected $primaryKey = 'id';
//public $timestamps = false;
protected $fillable = [ 'campaign_name', 'content', 'phone_no_list', 'send_time', 'status', 'merchant_id', 'send_type'];
}
传递 Carbon 实例:
SmsCampaign::whereBetween('created_at', [
Carbon::parse('2017-03-20 12:00:00'),
Carbon::parse('2017-03-20 23:59.00')
])->paginate(10);
我正在尝试从 table 中检索今天的值,在我的 table 中我有 created_at 列,这是插入行时自动分配的时间戳。我还有一个 send_at 列,我在其中手动插入日期时间,当我查询 send_at 范围时它可以工作,但是当我查询 created_at 列时,我什么也得不到。
$campaigns = SmsCampaign::whereBetween('created_at', array('2017-03-20 12:00:00','2017-03-20 23:59:00'))->paginate(10);
return view('sms_campaign.smscampaign')->with('campaigns', $campaigns);
型号:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SmsCampaign extends Model
{
protected $table = 'sms_campaign';
protected $primaryKey = 'id';
//public $timestamps = false;
protected $fillable = [ 'campaign_name', 'content', 'phone_no_list', 'send_time', 'status', 'merchant_id', 'send_type'];
}
传递 Carbon 实例:
SmsCampaign::whereBetween('created_at', [
Carbon::parse('2017-03-20 12:00:00'),
Carbon::parse('2017-03-20 23:59.00')
])->paginate(10);