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

Documentation - Moon rise and set times

Open mruk opened this issue 7 years ago • 1 comments

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

mruk avatar Aug 28 '17 22:08 mruk

@mruk Thank you.

somebadhat avatar Sep 05 '23 02:09 somebadhat