不确定发生了什么,但是mongodate总是在0秒内初始化。有什么想法导致这种想法吗?日期在服务器上是正确的..
$d = new MongoDate();
echo sprintf("%s -- %s \n",$d,$d->toDateTime()->format('Y-m-d H:i'));
0.52000000 1037164 - 1970-01-13 00:06
$d = new MongoDate(strtotime("2010-01-15 00:00:00"));
echo sprintf("%s -- %s \n",$d,$d->toDateTime()->format('Y-m-d H:i'));
0.52000000 10371640.97600000 793214 - 1970-01-10 04:20
答案 0 :(得分:0)
好吧,似乎mongodate-> todatestring只是不起作用。
所以......无论如何。 ¯\ _(ツ)_ /¯
从MongoDate-> sec构造你的日期时间对象,因为#php
$d = new MongoDate();
$slugDate = new DateTime();
$slugDate->setTimestamp($d->sec);
echo sprintf("mongodate= %s \n",$d->toDateTime()->format('Y-m-d H:i'));
echo sprintf("datetime from mongo = %s \n",$slugDate->format('Y-m-d H:i'));
$ mongodate = 1970-01-13 01:11
$ datetime from mongo = 2015-10-06 16:47