laravel - Displaying time in minutes/hours/days using Carbon or any other tools
问题描述
I want to convert date to make it like, if i posted comment 2 minutes ago it will show 2 minutes ago, if 2 hours ago, like that, week ago, and so on
<div class="col-md-2">
<p class="text-secondary text-center">{{ $comment->created_at }}</p>
</div>
解决方案
您需要使用 diffForHumans()
$comment->created_at->diffForHumans();
推荐阅读
- mongodb - 有没有办法在分离 mLab 插件之前检查哪个 mLab 帐户已连接到 heroku 应用程序?
- inno-setup - Inno Setup 中的#emit 指令有什么意义?
- javascript - 使用 Got、Nock 和 Chai 在 Node 中测试基本的异步 http 请求
- flutter - Api Authorization 在邮递员中工作但在颤振中不工作
- mongodb - 将字段添加到 Mongodb 中的特定行
- java - 在嵌套属性中覆盖 @JsonProperty
- python - 如何广播这个欧式距离?
- maven - 为什么刷新 Maven 存储库对于 IntelliJ 来说还不够?
- javascript - 选择带有背景图像的框?
- java - Gatling:如何分割从馈线获得的价值?