-1
您好我想在Laravel 4中使用DateTime,並且我不斷調用成員函數add()嘗試和使用添加功能,不能找出原因。在Laravel的日期時間 - 調用一個非對象的成員函數add()
這是我的代碼
if(isset($_POST['from']) && isset($_POST['direction']) && isset($_POST['product']) && isset($_POST['operator'])){
$businessid = mysql_real_escape_string($_POST['operator']);
$direction = mysql_real_escape_string($_POST['direction']);
$dateStart = DateTime::createFromFormat('D M d Y', $_POST['from']);
$dateEnd = DateTime::createFromFormat('D M d Y', $_POST['from']);
if($direction == 'first')
{
$dateEnd->add(new DateInterval('P14D'));
}
else if($direction == 'right')
{
$dateStart->add(new DateInterval('P1D'));
$dateEnd->add(new DateInterval('P7D'));
}
else if($direction == 'left')
{
$dateStart->sub(new DateInterval('P7D'));
if($dateStart < $todaysDate) { $dateStart = $todaysDate; }
$dateEnd->sub(new DateInterval('P1D'));
}
else if($direction == 'date')
{
$dateStart->sub(new DateInterval('P7D'));
while($dateStart < $todaysDate) { $dateStart->add(new DateInterval('P1D')); }
$dateEnd->add(new DateInterval('P10D'));
}
任何想法將是一個很大的幫助的感謝,