2016-07-04 114 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

工作,谢谢。我觉得太困难了 –