我正试图从表中检索今天的值,在我的表中,我已经创建了列,这是插入行时自动分配的时间戳。我还有一个send_at列,在其中手动插入datetime,当我使用一个范围查询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);

mysql - 如何获取指定日期范围内的值?-LMLPHP
型号:
<?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'];




}

最佳答案

通过碳实例:

SmsCampaign::whereBetween('created_at', [
        Carbon::parse('2017-03-20 12:00:00'),
        Carbon::parse('2017-03-20 23:59.00')
    ])->paginate(10);

关于mysql - 如何获取指定日期范围内的值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42898772/

10-15 18:54