php - (Yii)Datetime Validation fails -


i'd validate form input datetime article posted.

$model = new post('update');     $model->attributes = $_post['post'];          if($model->validate()){              //but, validation fails...              } 

this rule got check if input datetime format or not. used page(http://chris-backhouse.com/date-validation-in-yii/528) reference.

but validation error 'created'input.

public function rules() {     return array(          //datetime validation         array('created', 'date', 'message' => '{attribute}: not datetime!', 'format' => 'yyyy-mm-dd hh:mm:ss'),          ); } 

this have in $models-attribute.

array(1) { ["created"]=> string(19) "2013-08-01 00:00:01" } 

could knows how make work?

thanks lot in advance!!!

i advice use input formats in rule, since want custom formats.

array('created', 'date', 'format'=>'yyyy-mm-dd hh:mm:ss', 'message'=>'{attribute} have wrong format'), 

more date formats here - http://www.yiiframework.com/doc/api/1.1/cdatetimeparser


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -