PHPackages                             solaris/php-moon-phase - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. solaris/php-moon-phase

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

solaris/php-moon-phase
======================

Calculate the phases of the Moon in PHP.

v3.3.0(2mo ago)16562.0k↑107.3%441MITPHPPHP &gt;=8.2CI passing

Since Aug 29Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/BitAndBlack/php-moon-phase)[ Packagist](https://packagist.org/packages/solaris/php-moon-phase)[ Docs](https://github.com/BitAndBlack/php-moon-phase)[ Fund](https://www.buymeacoffee.com/tobiaskoengeter)[ RSS](/packages/solaris-php-moon-phase/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (9)Versions (14)Used By (1)

[![PHP from Packagist](https://camo.githubusercontent.com/8db1222c3a4badd20294feb072122125ff68fa5c760fc9c9ab1f8fb6f7458d9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6c617269732f7068702d6d6f6f6e2d7068617365)](http://www.php.net)[![Latest Stable Version](https://camo.githubusercontent.com/cdd837705f68a79ff14841105c839ee77b11c7c8d6afad8359e7926f2404ff4a/68747470733a2f2f706f7365722e707567782e6f72672f736f6c617269732f7068702d6d6f6f6e2d70686173652f762f737461626c65)](https://packagist.org/packages/solaris/php-moon-phase)[![Total Downloads](https://camo.githubusercontent.com/e4d83008b22610b66d079ca6d092113283259c287d48dd022fbbcc865d303150/68747470733a2f2f706f7365722e707567782e6f72672f736f6c617269732f7068702d6d6f6f6e2d70686173652f646f776e6c6f616473)](https://packagist.org/packages/solaris/php-moon-phase)[![License](https://camo.githubusercontent.com/dd3084baddf0906263d3420d1f1faf11e93e147d13b6f286eb2becf43e7cd1be/68747470733a2f2f706f7365722e707567782e6f72672f736f6c617269732f7068702d6d6f6f6e2d70686173652f6c6963656e7365)](https://packagist.org/packages/solaris/php-moon-phase)

Solaris PHP Moon Phase
======================

[](#solaris-php-moon-phase)

Calculate the phases of the Moon in PHP. This library is based on [Moontool for Windows](http://www.fourmilab.ch/moontoolw/).

Installation
------------

[](#installation)

This library is made for the use with [Composer](https://packagist.org/packages/solaris/php-moon-phase). Add it to your project by running `$ composer require solaris/php-moon-phase`.

Usage
-----

[](#usage)

Create an instance of the `MoonPhase` class, supplying a `DateTime` object with a UNIX timestamp for when you want to determine the moon phase (if you don't then the current time will be used).

You can then use the following methods:

- `getPhase()`: the terminator phase angle as a fraction of a full circle (i.e., `0` to `1`). Both `0` and `1` correspond to a New Moon, and `0.5` corresponds to a Full Moon.
- `getIllumination()`: the illuminated fraction of the Moon (`0` = New, `1` = Full).
- `getAge()`: the age of the Moon, in days.
- `getDistance()`: the distance of the Moon from the centre of the Earth (kilometres).
- `getDiameter()`: the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth (degrees).
- `getSunDistance()`: the distance to the Sun (kilometres).
- `getSunDiameter()`: the angular diameter subtended by the Sun as seen by an observer at the centre of the Earth (degrees).
- `getPhaseNewMoon()`: the time of the New Moon in the current lunar cycle, i.e., the start of the current cycle (UNIX timestamp).
- `getPhaseNextNewMoon()`: the time of the New Moon in the next lunar cycle, i.e., the start of the next cycle (UNIX timestamp).
- `getPhaseFullMoon()`: the time of the Full Moon in the current lunar cycle (UNIX timestamp).
- `getPhaseNextFullMoon()`: the time of the Full Moon in the next lunar cycle (UNIX timestamp).
- `getPhaseFirstQuarter()`: the time of the first quarter in the current lunar cycle (UNIX timestamp).
- `getPhaseNextFirstQuarter()`: the time of the first quarter in the next lunar cycle (UNIX timestamp).
- `getPhaseLastQuarter()`: the time of the last quarter in the current lunar cycle (UNIX timestamp).
- `getPhaseNextLastQuarter()`: the time of the last quarter in the next lunar cycle (UNIX timestamp).
- `getPhaseName()`: the [phase name](https://aa.usno.navy.mil/faq/moon_phases).

### Example

[](#example)

```
