Lakmal Vithanage
Lakmal Vithanage

Reputation: 2777

Unix_Timestamp to mongo

there is a mysql query as follow,

SELECT Unix_Timestamp(last_executed)
    FROM mpres_seq

now i need to do same thing in php with MongoDB. In mongodb i have saved last_executed as ISO Date. How can i do that? if i used $collection = $global["dbmongo"] -> mpres_seq; $res = $collection->find(),array("last_executed"=>1,"_id"=>0));

Is it work for me. I want to get last_executed, in same type and same pattern in mysql

Upvotes: 0

Views: 196

Answers (1)

Sammaye
Sammaye

Reputation: 43884

You simply print out the secs of the MongoDate:

foreach($res as $row){
    echo $doc['last_executed']->sec;
}

Reference:

http://php.net/manual/en/class.mongodate.php

Upvotes: 1

Related Questions