The Timestampable behavior automatically saves the date of creation and/or update in the documents.
array(
'Model\Article' => array(
'fields' => array(
'title' => 'string',
'content' => 'string',
),
'behaviors' => array(
array('class' => 'Mandango\Behavior\Timestampable'),
),
),
);
createdEnabled
(default true): whether to save the creation datecreatedField
(default 'created_at'): field used to store the creation dateupdatedEnabled
(default true): whether to save the update dateupdatedField
(default 'updated_at'): field used to store the update date
$article = $mongator->create('Model\Article')->setTitle('Mongator')->save();
echo $article->getCreatedAt(); // new \DateTime('now')
echo $article->getUpdatedAt(); // null
$article->setContent('Content')->save();
echo $article->getCreatedAt(); // the same \DateTime()
echo $article->getUpdatedAt(); // new \DateTime('now')