Inserting a date in mongodb

前端 未结 4 619
臣服心动
臣服心动 2020-12-31 06:55

I want to insert a date into a collection. I use the class MongoDate to create the date object:

$today = new MongoDate(strtotime(date(\'Y-m-d 00         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 07:20

    $dt = new DateTime(date('Y-m-d'), new DateTimeZone('UTC'));
    $ts = $dt->getTimestamp();
    $today = new MongoDate($ts);
    

    This is working.

提交回复
热议问题