Beforesave Doesn't Work In Yii To Store Expiry Date

beforesave doesnt work in yii … here i go before i create a record in tbl1 i need to assign the expiry date in tbl1 ie., done by adding tbl2 duration following is the code

$end_date = date("Y-m-d H:i:s", strtotime($today . " +  $duration days ")); (this line gives the error)

if ($this->isNewRecord){

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

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





		$sql2="select duration

			from tbl2

			where ( pid=". $_GET['pid'] ." and sid=". $sid.")";




			$end_date = date("Y-m-d H:i:s", strtotime($today . " +  $duration days ")); (this line gives the error)


it stores 1970-01-01 00:00:00 as expiry date

Please let me know am losing my mind on this

$today is a CDbExpression, strtotime doesn’t know what to do with it. You’re also passing it wrong and you don’t need it:

$end_date = date("Y-m-d H:i:s", strtotime("+$duration days"));

but the i got to add $todays date and the duration … will it work with just $duration do i not require $todays

On under Examples you can see that you don’t need it for the current date.

thanks it worked

my need is to find know days left between $expirydate and $today(i.e., currentday)

$today=date('Y-m-d H:i:s');

$interval = $today->diff($expirydate);

echo $interval;

use timestamps and/or google.

[quote=“guaruja, post:7, topic:67582”]

use timestamps and/or google.

[/quote ]

the thing is my expirydate is being stored in db i got to know the days left i.e.,expirydate - current date .i din’t get you can you please explain what exactly you wanna say