how to set the hidden field with time value?

Please help me on this. I was unable to store the time into database.

<?php echo $form->hiddenField($model,'timesheet_timein',array('value'=>10:00:00)); ?>

The easiest way to debug this is to check the HTML source of the page (is the value being set correctly on the HTML output?) and what format does your database require the timestamp to be in?

In your example I think you’re also missing some quotation marks,

<?php echo $form->hiddenField($model,'timesheet_timein',array('value'=>'10:00:00')); ?>

Notice the single quotes around the actual time value.

try after adding below to model rules

array('timesheet_timein', 'safe'),


If the field is gonna be automatically filled, I’d suggest that you try to set the value in your model instead of inserting it as hidden field in the form, once the form could be easily hacked by some advanced user…so in your model try the following:

public function beforeSave(){

    $this->timesheet_timein = new CDbExpression('NOW()');

    return parent::beforeSave();


this have worked very fine to me untill now.

Hope this helps!



Thx for the solution. Problem solved.

Thanks… My pblm solved