我尝试仅获取用户的created_at
日期,但同时也提取时间。代码:
{{{ isset(Auth::user()->created_at) ? Auth::user()->created_at : Auth::user()->email }}}
结果:2017-05-09 11:44:09
答案 0 :(得分:9)
您可以使用toDateString()
{{ isset(Auth::user()->created_at) ? Auth::user()->created_at->toDateString() : Auth::user()->email }}
或format()
{{ isset(Auth::user()->created_at) ? Auth::user()->created_at->format('m/d/Y') : Auth::user()->email }}
答案 1 :(得分:3)
我还有其他解决方案:
where('created_at', '>=', date('Y-m-d').' 00:00:00'));
whereDate('created_at', '=', date('Y-m-d'));
whereDate('created_at', '=', Carbon::today()->toDateString());
它将100%工作