【发布时间】:2018-09-05 09:42:03
【问题描述】:
我正在使用 Laravel,我当然想显示格式化的 created_at 时间戳,但仅在 id = 1 时显示,所以是最新的。
public function statistics(){
$first = DB::table('articles')
->select('created_at')
->where('id', '=', 1)
->get();
return view('pages.statistics')->with('first', $first);;
}
刀片:
{{ $first}}
我想要一个格式化的日期,但是当我使用日期功能时,它会自动将日期设置为 01.01.1970
这是我得到的:
[{"created_at":"2018-08-23 11:45:34"}]
我应该使用 Carbon 吗?如果可以,如何使用?
【问题讨论】:
-
你能解释更多吗?你在哪里格式化来自数据库的日期??
-
你需要通过 $first->created_at 得到这个