suncalc-php
suncalc-php copied to clipboard
Documentation - Moon rise and set times
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 Thank you.