suncalc-php icon indicating copy to clipboard operation
suncalc-php copied to clipboard

error code

Open pketola opened this issue 9 years ago • 1 comments

I'll get an error code:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\Apache\htdocs\moon2\suncalc.php on line 44

which is:

function fromJulian($j) { $dt = new DateTime("@".round(($j + 0.5 - J1970) * daySec)); $dt->setTimezone((new DateTime())->getTimezone()); return $dt; }

the line is

$dt->setTimezone((new DateTime())->getTimezone());

PHP/5.3.27

any ideas?

pketola avatar Jun 15 '16 13:06 pketola

The syntax (new DateTime())->getTimezone(), ie. calling a method directly on a newly created object, was introduced in PHP 5.4. You'll have to use a intermediary variable.

gregseth avatar Jun 15 '16 14:06 gregseth