I have the following code to create a virtual attribute "mydob".
public function getMyDOB()
{
return date('m/d/Y', CDateTimeParser::parse($this->dob, 'yyyy-MM-dd'));
}
The problem is that if $this->dob is undefined (such as when I am creating instead of updating), this returns the date of the Unix epoch. Any ideas on how I can check to see if $this->dob is defined before I return?
Use the Yii::log() method, in your config/main.php you can configure the log level by adding the "info" level, by default is not set, look at your config/main.php
Yii::log("My dob is:".[/color][color=#000000]$this[/color][color=#666600]->[/color][color=#000000]dob[/color],"info"); // use the Yii::log [color=#000088]return[/color][color=#000000] date[/color][color=#666600]([/color][color=#008800]'m/d/Y'[/color][color=#666600],[/color][color=#000000] [/color][color=#660066]CDateTimeParser[/color][color=#666600]::[/color][color=#000000]parse[/color][color=#666600]([/color][color=#000000]$this[/color][color=#666600]->[/color][color=#000000]dob[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]'yyyy-MM-dd'[/color][color=#666600]));[/color][color=#666600]}[/color]