I have a strange error with MongoDate.
First: the system is a virtual machine on a Mac server.
Linux vm 3.16.0-33-generi # 44 ~ 04.14.1-Ubuntu SMP Fri Mar 13 10:32:52 UTC 2015 i686 i686 i686 GNU / Linux
<?php
$n = 1420124400;
echo $n."\n";
$d = new MongoDate($n);
var_dump( $d );
var_dump( $d->toDateTime() );
var_dump( new DateTime("@".$d->sec) );
?>
I got this result:
object(MongoDate)#1 (2) {
["sec"]=>
int(1420124400)
["usec"]=>
int(0)
}
object(DateTime)#2 (3) {
["date"]=>
string(19) "1969-12-14 12:37:05"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
object(DateTime)#2 (3) {
["date"]=>
string(19) "2015-01-01 15:00:00"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
The second dump shows an invalid date created by MongoDate-> toDateTime (). The date value stored in the datetime object is until 1970.
Thank,
Patrick
source
share