gregseth / suncalc-php

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

Documentation - Moon rise and set times #11

Open mruk opened 7 years ago

mruk commented 7 years ago

Now in doc there is:

... an object with the following indexes: rise: moonrise time as DateTime set: moonset time as DateTime

But, when i checked:

$moonTimes = $sc->getMoonTimes();
foreach ($moonTimes as $key => $val) {
      echo $key.'</br>';
}

The result is:

moonrise moonset

Which lead me to the usage:

$moonTimes = $sc->getMoonTimes();
$moonriseStr = $moonTimes['moonrise']->format('H:i');
$moonsetStr = $moonTimes['moonset']->format('H:i');

Otherwise i am getting an error. So, concluding, the proper use case of getMoonTimes() is:

$sc = new SunCalc(new DateTime(), $lat(), $lon());
$moonTimes = $sc->getMoonTimes();
$moonriseStr = $moonTimes['moonrise']->format('H:i');
$moonsetStr = $moonTimes['moonset']->format('H:i');
somebadhat commented 1 year ago

@mruk Thank you.