2016-07-04 63 views
0
if(!empty($maintenance_options['disable'])) { 
    $currentDate = date("Y-m-d H:i:s", strtotime(date("Y-m-d") . date("H:i:s"))); 
    $nodate = $maintenance_options['disable'], strtotime(date("Y-m-d") . date("H:i:s")); 

    if($currentDate > $nodate) { 
     echo 'if'; 
    } else { 
     echo 'else'; 
    } 
} 

我有這個奇怪的錯誤:PHP的strtotime問題,導致錯誤

Parse error: syntax error, unexpected ',' on line 53

53號線是

$nodate = $maintenance_options['disable'], strtotime(date("Y-m-d") . date("H:i:s")); 

,但該行似乎是罰款?它出什麼問題了?

+0

該行是否打算作爲函數調用?分號前有一個額外的右括號。 –

+0

什麼是日期(「Y-m-d」)。日期(「H:我:S」)應該是?如果你只是想要當前時間,使用time()而不是strtotime(date(「Y-m-d」)。date(「H:i:s」)) – Nick

+0

@EduardoGalván什麼「右括號」?它們全都匹配 –

回答

0

這個問題有點難理解,但我想我知道要問什麼。看來$ currentDate需要是當前的PHP時間,而$ nodate需要設置爲$ maintenance_options ['disable']的時間值。如果這是真的,下面的代碼應該工作。

$currentDate = time(); 
$nodate = strtotime($maintenance_options['disable']); 
+0

工作,謝謝。我覺得太困難了 –