我有mongo数据库,其中包含这样的时间值
“时间”:ISODate(“ 2019-11-28T12:51:38.827Z”),
当我使用laravel从数据库中获得此值时,我会这样获得
“时间”:{“ $日期”:{“ $ numberLong”:“ 1574945497100”}}
我需要将此值转换为可读日期,我在互联网解决方案中找到了要使用的
MongoDB \ BSON \ UTCDateTime
class,但是当我应用此代码时
Add role assignment
我遇到此错误
找不到类'App \ Http \ Controllers \ MongoDB \ BSON \ UTCDateTime'
我在php中安装了mongodb驱动程序
Owner
我不知道laravel为什么看不到此类
答案 0 :(得分:0)
在MongoDB之前加斜杠
$utcdatetime = new \MongoDB\BSON\UTCDateTime(1416445411987);
$datetime = $utcdatetime->toDateTime();