使用Laravel MongoDB在html表中显示日期 [英] Show date in html table using Laravel MongoDB

查看:73
本文介绍了使用Laravel MongoDB在html表中显示日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Carbon API格式化日期,这是我在视图中编写的代码:
<td>{{ Carbon\Carbon::parse('@'.$item->time)->format('d-m-Y H-i-s-e') }}</td>

I'm using Carbon API to format date, here is a code I write in view:
<td>{{ Carbon\Carbon::parse('@'.$item->time)->format('d-m-Y H-i-s-e') }}</td>

我看到的日期与MongoDB中存储的数据不匹配,在MongoDB中,日期为ISODate("2018-03-31T01:08:50.000+0000"),但是我得到了"16-10-50214 19-13-20-+00:00".

Date I get in view didn't match with data stored in MongoDB, In MongoDB date is ISODate("2018-03-31T01:08:50.000+0000") but I get "16-10-50214 19-13-20-+00:00".

推荐答案

经过大量搜索,如果您使用的是mongodb,我发现了一种最佳的方法来查看刀片中的日期:

After a lot of searching, I found a best solution to view date in blade if you are using mongodb:

{{ $item['time']->toDateTime()->format('d-m-Y H:i:s e') }}

这篇关于使用Laravel MongoDB在html表中显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆