Skip to content
Advertisement

Mongodb php datetime filter not working properly

I use mongo db with php I need a last 1 hour data. I implement as like bellow.

JavaScript

PHP CODE

JavaScript

I need a count result. thanks in advance

Advertisement

Answer

I am not so familiar with PHP, but I think $client->$db_name is equal to $client->selectDatabase($db_name)

However -> does not work with variables, so $client->$db_name may fail.

Try this one:

JavaScript

I never used strtotime, maybe you have to skip * 1000

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement