【发布时间】:2014-08-05 20:45:34
【问题描述】:
我在 MongoDB 中存储了 ISO 日期。
> db.myDB.find()
{ "_id" : ObjectId("..."), "time" : ISODate("2014-08-05T11:18:55Z) }
当我在 PHP 中回显它时,它的显示方式与数据库不同。
echo $document["time"] // Prints 0.00000000 1407236935
零是怎么回事?它以什么格式打印?有没有一种我可以使用的格式可以打印得更好,以便人类可以精确到分钟来确定它?
【问题讨论】:
-
因为您正在使用该对象的字符串表示形式,请尝试访问该类的 sec 属性:php.net/manual/en/class.mongodate.php
标签: php mongodb date timestamp iso