Php查询到Mongodb日期对象

Can somebody tell me please what is the best practice to query Mongodb date object via PHP? Mongo driver has a lot of strange classes like MongoDB\BSON\Undefined or MongoDB\BSON\UTCDateTime... Now I want to send query to Mongodb which could look like

$collection->find(['publishDate' => new DateTime()])

Its simple and clear. My question is - Is is possible to od it this way or I need to write something like

$collection->find(['publishDate' => new MongoDB\BSON\UTCDateTime( microtime() )])

What is the best practice? Thanks.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问