Skip to content

Documentation - Moon rise and set times #11

Description

@mruk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions