Printing A MongoDB Date From PHP

前端 未结 5 451
忘了有多久
忘了有多久 2020-12-28 17:53

How in PHP do I get the regular timestamp format out of a MongoDB date?

Assume I have:

$my_date;
print_r($my_date);
         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 18:23

    Just a quick update, to say that MongoDate has a toDateTime method since the version 1.6 of the pecl extension. You can now do

    $mongoDate->toDateTime()->format(...)
    

提交回复
热议问题