I have a strange error with MongoDate.
First: The system is a virtual machine on a mac server.
Linux vm 3.16.0-33-generic #44~14.04.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 the invalid date, generated by MongoDate->toDateTime(). The date value stored in the datetime object is before 1970.
Thank you,
Patrick