该代码中输出错误日期的问题是什么?
$date = "1990-05-07"; // Y-m-d
$date1 = date("d/m/Y", strtotime($date)); // Here is fine.
$date2 = date("Y-m-d", strtotime($date1)); // Here is wrong.
echo $date2; // output: 1990-07-05
上面的代码是一个简单的演示,具体代码是:(Yii Framework)
模型.php
public function afterFind()
{
if ($this->birthday)
{
$this->birthday = date("d/m/Y", strtotime($this->birthday));
}
}
public function beforeSave()
{
if ($this->birthday)
{
$this->birthday = date("Y-m-d", strtotime($this->birthday));
}
}