= Timestampable Behavior = The `timestampable` behavior allows you to keep track of the date of creation and last update of your model objects. == Basic Usage == In the `schema.xml`, use the `` tag to add the `timestampable` behavior to a table: {{{ #!xml
}}} Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has two new columns, `created_at` and `updated_at`, that store a timestamp automatically updated on save: {{{ #!php setTitle('War And Peace'); $b->save(); echo $b->getCreatedAt(); // 2009-10-02 18:14:23 echo $b->getUpdatedAt(); // 2009-10-02 18:14:23 $b->setTitle('Anna Karenina'); $b->save(); echo $b->getCreatedAt(); // 2009-10-02 18:14:23 echo $b->getUpdatedAt(); // 2009-10-02 18:14:25 }}} The object query also has specific methods to retrieve recent objects and order them according to their update date: {{{ #!php recentlyUpdated() // adds a minimum value for the update date ->lastUpdatedFirst() // orders the results by descending update date ->find(); }}} You can use any of the following methods in the object query: {{{ #!php }}} {{{ #!php setTitle('War And Peace'); $b->save(); echo $b->getMyCreateDate(); // 2009-10-02 18:14:23 echo $b->getMyUpdateDate(); // 2009-10-02 18:14:23 $b->setTitle('Anna Karenina'); $b->save(); echo $b->getMyCreateDate(); // 2009-10-02 18:14:23 echo $b->getMyUpdateDate(); // 2009-10-02 18:14:25 }}}