PHPackages                             jiri.jozif/moonriset - 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. jiri.jozif/moonriset

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

jiri.jozif/moonriset
====================

PHP library for calculating moonrise and moonset

1.0.3(1y ago)119MITPHPPHP &gt;=8.1

Since Feb 18Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/JiriJozif/moonriset)[ Packagist](https://packagist.org/packages/jiri.jozif/moonriset)[ RSS](/packages/jirijozif-moonriset/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

[![Moonriset](https://raw.githubusercontent.com/JiriJozif/moonriset/main/moonriset.png)](https://raw.githubusercontent.com/JiriJozif/moonriset/main/moonriset.png)

PHP library for calculating Moon rise, set and transit
======================================================

[](#php-library-for-calculating-moon-rise-set-and-transit)

Algorithm source: Oliver Montenbruck and Thomas Pfleger: Astronomy on the Personal Computer, Springer-Verlag 1994

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

[](#installation)

This library is available for use with [Composer](https://packagist.org/packages/jiri.jozif/moonriset) — add it to your project by running:

```
$ composer require jiri.jozif/moonriset
```

Usage
-----

[](#usage)

Create an instance of the `Moonriset` class with up to three optional parameters:

- **$latitude** (float, optional): The latitude of the location (default: `ini_get('date.default_latitude')`).
- **$longitude** (float, optional): The longitude of the location (default: `ini_get('date.default_longitude')`).
- **$timezone** (string, optional): The timezone for the location (default: `date_default_timezone_get()`). The calculation is automatically performed for today

You can then use the following methods:

- `setDate($year, $month, $day)`: Sets the date for which the calculation will be performed.
    - **$year** (integer): The year (e.g., 2025).
    - **$month** (integer): The month (e.g., 1 for January, 12 for December).
    - **$day** (integer): The day of the month (e.g., 15).

The following properties of the `Moonriset` class provide the calculated times in different formats:

- `rise['timestamp']`: UNIX timestamp the moon rises or `true` is Moon continuously above horizon or `false` if Moon continuously below horizon
- `rise['hh_mm']`: Time the moon rises as string in hh:mm format or "**:**" Moon continuously above horizon or "--:--" Moon continuously below horizon
- `rise['hhmm']`: Time the moon rises as string in hhmm format or "\*\*\*\*" Moon continuously above horizon or "----" Moon continuously below horizon
- `set['timestamp']`: UNIX timestamp the moon sets or `true` is Moon continuously above horizon or `false` if Moon continuously below horizon
- `set['hh_mm']`: Time the moon sets as string in hh:mm format or "**:**" Moon continuously above horizon, or "--:--" Moon continuously below horizon
- `set['hhmm']`: Time the moon sets as string in hhmm format or "\*\*\*\*" Moon continuously above horizon or "----" Moon continuously below horizon
- `transit['timestamp']`: UNIX timestamp the moon transit or `null` if transit does not occur
- `transit['hh_mm']`: Time the moon transit as string in hh:mm format
- `transit['hhmm']`: Time the moon transit as string in hhmm format
- `rise2['timestamp']`: UNIX timestamp the second moon rises (an exceptional phenomenon near the Arctic Circle)
- `rise2['hh_mm']`: Time the second moon rises as string in hh:mm format (an exceptional phenomenon near the Arctic Circle)
- `rise2['hhmm']`: Time the second moon rises as string in hhmm format (an exceptional phenomenon near the Arctic Circle)
- `set2['timestamp']`: UNIX timestamp the second moon sets (an exceptional phenomenon near the Arctic Circle)
- `set2['hh_mm']`: Time the second moon sets as string in hh:mm format (an exceptional phenomenon near the Arctic Circle)
- `set2['hhmm']`: Time the second moon sets as string in hhmm format (an exceptional phenomenon near the Arctic Circle)

### Example

[](#example)

```
