Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

save date time in ODM

How can I create ISODate object in mongodb using ODM?


$object->dateCreated = "new ISODate()"; 
$object->save();

it saves plain text.. and I need that date object. Is there a way?

Thanks



7.0k
Accepted
answer
edited Dec '14

Found solution:


$object->dateCreated = new \MongoDate(time());
$object->save();