gregseth / suncalc-php

PHP library for basic astronomical computation (sun and moon rise and set, moon phases, …)
GNU General Public License v2.0
65 stars 20 forks source link

error code #1

Open pketola opened 8 years ago

pketola commented 8 years ago

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?

gregseth commented 8 years ago

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.