I use lithium console (lithium/console/li3) to run some command and I get this error:
PHP Fatal error: Class 'MongoDate' not found
My system details:
$Requests = Requests::find('all', array('conditions'=>array(
'expired'=>array('<'=>new \MongoDate(time())),
'processed'=>0
)));
I don't have this error while running this code in older version system
Thank you.
One more thing: I try to create just a simple script
$date = new MongoDate();
it runs without problem via webserver (browser) but if I use php command to run this file, I get the same error: Class 'MongoDate' not found
So I believe that it's php command problem.
For people that have come here using PHP7, the classs has been renamed:
MongoDate
is now MongoDB\BSON\UTCDateTime
Also I've found that this now wants miliseconds instead of seconds, so make sure you multiple your input by 1000, for example:
$date = new \MongoDB\BSON\UTCDateTime(strtotime('yesterday') * 1000);
Make sure your mongodb
extension is loaded.
var_dump(extension_loaded('mongodb'));
If not, you must load it in php.ini
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With