所以我有這個奇怪的問題,我真的不明白。我只是想用兩個日期時間,「開始時間」和「結束時間」爲一個對象提供保溼。我通過(在本例中3天)加入DateIntervalDateTime Symfony2保溼/持久
在這裏得到的結束時間是我的控制器
$datenow = new \DateTime('now');
var_dump($dateNow);
$relation->setDateAjout($dateNow);
$date = $dateNow;
$duration=(string)$flower->getDuration();
$dateEnd=$date->add(new \DateInterval('P'.$duration.'D'));
var_dump($dateEnd);
$relation->setDateFin($dateEnd);
$em = $this->getDoctrine()->getManager();
$em->persist($relation);
$em->flush();
制定者,似乎罰款
/**
* Set dateAjout
*
* @param \DateTime $dateAjout
* @return Fleur
*/
public function setDateAjout($dateAjout)
{
$this->dateAjout = $dateAjout;
return $this;
}
/**
* Set dateFin
*
* @param \DateTime $dateFin
* @return Fleur
*/
public function setDateFin($dateFin)
{
$this->dateFin = $dateFin;
return $this;
}
什麼VAR轉儲顯示(涼)
object(DateTime)[368]
public 'date' => string '2014-10-02 12:41:17' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Paris' (length=12)
object(DateTime)[368]
public 'date' => string '2014-10-05 12:41:17' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Paris' (length=12)
phpmyadmin result(not cool)
2014-10-05 12:41:17
and
2014-10-05 12:41:17
感謝,不知道有關 – oligan 2014-10-02 11:02:12