将日期时间转换为人类可理解的形式
Convert a datetime into human understandable form
laravel 中有一个名为 Carbon
的 class,它用于将日期格式化为他们所谓的 diffForHumans()
。所以,我有一个看起来像这样的日期:
2018-07-15 17:03:19
那么,如何将其转换为 diffForHumans
?谢谢!
像这样:
$date = \Carbon\Carbon::parse("2018-07-15 17:03:19")->diffForHumans();
认真的?我因为回答他的问题而被否决?
鉴于您使用 Laravel 我认为您使用的是 Twig。您可以显示 {{ yourDate |date("m/d/Y") }}
之类的日期,其中 yourDate
是日期的变量。阅读更多 here.
laravel 中有一个名为 Carbon
的 class,它用于将日期格式化为他们所谓的 diffForHumans()
。所以,我有一个看起来像这样的日期:
2018-07-15 17:03:19
那么,如何将其转换为 diffForHumans
?谢谢!
像这样:
$date = \Carbon\Carbon::parse("2018-07-15 17:03:19")->diffForHumans();
认真的?我因为回答他的问题而被否决?
鉴于您使用 Laravel 我认为您使用的是 Twig。您可以显示 {{ yourDate |date("m/d/Y") }}
之类的日期,其中 yourDate
是日期的变量。阅读更多 here.