PHPackages                             linkorb/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. linkorb/php-moon-phase

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

linkorb/php-moon-phase
======================

A PHP class for calculating the phase of the Moon.

019.7k↓61.5%PHP

Since Aug 23Pushed 12y ago1 watchersCompare

[ Source](https://github.com/erikscheepers/php-moon-phase)[ Packagist](https://packagist.org/packages/linkorb/php-moon-phase)[ RSS](/packages/linkorb-php-moon-phase/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

A PHP class for calculating the phase of the Moon.
==================================================

[](#a-php-class-for-calculating-the-phase-of-the-moon)

php-moon-phase is a PHP class for calculating the phase of the Moon, and other related variables. It is based on [Moontool for Windows](http://www.fourmilab.ch/moontoolw/).

Usage
-----

[](#usage)

Include the moon-phase.php file in your script, and then simply create an instance of the `MoonPhase` class, supplying 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 class functions to access the properties of the object:

- `phase()`: 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.
- `illumination()`: the illuminated fraction of the Moon (0 = New, 1 = Full).
- `age()`: the age of the Moon, in days.
- `distance()`: the distance of the Moon from the centre of the Earth (kilometres).
- `diameter()`: the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth (radians).
- `sundistance()`: the distance to the Sun (kilometres).
- `sundiameter()`: the angular diameter subtended by the Sun as seen by an observer at the centre of the Earth (radians).
- `new_moon()`: the time of the last New Moon (UNIX timestamp).
- `next_new_moon()`: the time of the next New Moon (UNIX timestamp).
- `full_moon()`: the time of the Full Moon in the current lunar cycle (UNIX timestamp).
- `first_quarter()`: the time of the first quarter in the current lunar cycle (UNIX timestamp).
- `last_quarter()`: the time of the last quarter in the current lunar cycle (UNIX timestamp).

### Example

[](#example)

```
include 'moon-phase.php';

// create an instance of the class, and use the current time
$moon = new MoonPhase();
$age = round( $moon->age(), 1 );
$stage = $moon->phase() < 0.5 ? 'waxing' : 'waning';
$distance = round( $moon->distance(), 2 );
$next = gmdate( 'G:i:s, j M Y', $moon->next_new_moon() );
echo "The moon is currently $age days old, and is therefore $stage. ";
echo "It is $distance km from the centre of the Earth. ";
echo "The next new moon is at $next.";

```

Help
----

[](#help)

For bugs/enhancements, feel free to either raise an issue or pull request in GitHub, or [contact me](http://rayofsolaris.net/contact/).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3470061?v=4)[Erik Scheepers](/maintainers/erikscheepers)[@erikscheepers](https://github.com/erikscheepers)

---

Top Contributors

[![solarissmoke](https://avatars.githubusercontent.com/u/160227?v=4)](https://github.com/solarissmoke "solarissmoke (10 commits)")

### Embed Badge

![Health badge](/badges/linkorb-php-moon-phase/health.svg)

```
[![Health](https://phpackages.com/badges/linkorb-php-moon-phase/health.svg)](https://phpackages.com/packages/linkorb-php-moon-phase)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
