php - How does Yii timestamps work? -


yii says can automatically set timestamps 'created_at': http://www.yiiframework.com/doc-2.0/guide-concept-behaviors.html#using-timestampbehavior

however, every time created record, time blank:

$ yii kw/test 1437683634  mysql> select * ad_group_keyword_network ad_group_keyword_id = 1; +---------------------+- | created_at          |  +---------------------+- | 0000-00-00 00:00:00 |  | 0000-00-00 00:00:00 |  +---------------------+-    public function actiontest() {     $agkn = new adgroupkeywordnetwork();     $agkn->save();     echo $agkn->created_at; 

i tried schema::type_timestamp , changed field , tried schema::type_datetime. both return integer timestamp in field after save, time 0s in database.

public function behaviors() {     return [         [             'class' => timestampbehavior::classname(),             'attributes' => [                 activerecord::event_before_insert => ['created_at'],                 activerecord::event_before_update => [], 

your created_at must type int (11) yii 2 timestamp behaviour work. think using type timestamp not work.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -