Search options. create_time and user_id...convert to timezone and username.

Dear all,

I am doing search in my index.php. Here is my code:

In _search.php

<div class="wide form">


$form=$this->beginWidget('CActiveForm', array(



)); ?>

	<div class="row">

		<?php echo $form->label($model,'name'); ?>

		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>256)); ?>


	<div class="row">

		<?php echo $form->label($model,'owner_id'); ?>

		<?php echo $form->textField($model,'owner_id'); ?>


	<div class="row">

		<?php echo $form->label($model,'create_time'); ?>

		<?php echo $form->textField($model,'create_time'); ?>


	<div class="row buttons">

		<?php echo CHtml::submitButton('Search'); ?>


<?php $this->endWidget(); ?>

</div><!-- search-form -->

Is there a way to change owner_id to username?

And change create_time to timezone? For example, 1 week ago, 2 days ago…etc.

Or should I do this in my Model?

$criteria=new CDbCriteria;







using AR, you must declare the relation in your model

	public function relations()


		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'user' => array(self::BELONGS_TO, 'User', 'user_id'), 




And in the search you can use somthing like this:

		$criteria=new CDbCriteria;

		$criteria->with = array( 'user');

		$criteria->compare( '"user".user_lastname', $this->user_search,true);


Then you can ask a name in your search form.