2017 © Pedro Peláez
 

library php-moon-phase

A PHP class for calculating the phase of the Moon.

image

solaris/php-moon-phase

A PHP class for calculating the phase of the Moon.

  • Saturday, February 7, 2015
  • by solaris
  • Repository
  • 12 Watchers
  • 84 Stars
  • 3,986 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 32 Forks
  • 4 Open issues
  • 5 Versions
  • 12 % Grown

The README.md

PHP from Packagist Latest Stable Version Total Downloads License, (*1)

Solaris PHP Moon Phase

Calculate the phases of the Moon in PHP. This library is based on Moontool for Windows., (*2)

Installation

This library is made for the use with Composer. Add it to your project by running $ composer require solaris/php-moon-phase., (*3)

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)., (*4)

You can then use the following methods:, (*5)

  • 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.

Example

<?php

use Solaris\MoonPhase;

$moonPhase = new MoonPhase();

$age = round($moonPhase->getAge(), 1);
$stage = $moonPhase->getPhase() < 0.5 ? 'waxing' : 'waning';
$distance = round($moonPhase->getDistance(), 2);
$next = gmdate('G:i:s, j M Y', (int) $moonPhase->getPhaseNextNewMoon());

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

If you have any questions, feel free to contact us under hello@bitandblack.com., (*6)

Further information about Bit&Black can be found under www.bitandblack.com., (*7)

The Versions

07/02 2015

dev-master

9999999-dev http://www.github.com/solarissmoke/php-moon-phase

A PHP class for calculating the phase of the Moon.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php moon phase

07/02 2015

v1.2

1.2.0.0 http://www.github.com/solarissmoke/php-moon-phase

A PHP class for calculating the phase of the Moon.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php moon phase

24/01 2015

v1.1.1

1.1.1.0 http://www.github.com/solarissmoke/php-moon-phase

A PHP class for calculating the phase of the Moon.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php moon phase

25/01 2014

v1.1.0

1.1.0.0 http://www.github.com/solarissmoke/php-moon-phase

A PHP class for calculating the phase of the Moon.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php moon phase

29/08 2013

v1.0.0

1.0.0.0 http://www.github.com/solarissmoke/php-moon-phase

A PHP class for calculating the phase of the Moon.

  Sources   Download

The Requires

  • php >=5.3.0

 

php moon phase