J. Doe J. Doe - 1 year ago 85
PHP Question

PHP strtotime issue, causing error

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';

I have this weird error:

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

Line 53 is

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

but that line seems to be fine? What's wrong with it?

Answer Source

The question was a bit hard to understand, but I think I know what's being asked. It appears that $currentDate needs to be the current PHP time and $nodate needs to be set to the time value of $maintenance_options['disable']. If this is true, the following code should work.

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