laravel需要使用carbon类仅显示日期而不是时间 [英] laravel need to display only date not time using the carbon class
本文介绍了laravel需要使用carbon类仅显示日期而不是时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前我正在使用
Carbon :: now()
Carbon::now()
它显示
2015-03-10 23:23:46
2015-03-10 23:23:46
但我只需要
2015-03-10
推荐答案
http://carbon.nesbot.com/docs/#api-formatting
$dt = Carbon::now();
echo $dt->toDateString(); // Equivalent: echo $dt->format('Y-m-d');
这篇关于laravel需要使用carbon类仅显示日期而不是时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文