PHPackages                             tuxonice/suncalc-php - 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. tuxonice/suncalc-php

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

tuxonice/suncalc-php
====================

Sun and moon calculations for PHP

v1.0.1(5mo ago)0386↓31.8%GPL-2.0-or-laterPHPPHP ^8.0CI passing

Since Dec 15Pushed 5mo agoCompare

[ Source](https://github.com/tuxonice/suncalc-php)[ Packagist](https://packagist.org/packages/tuxonice/suncalc-php)[ RSS](/packages/tuxonice-suncalc-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

SunCalc PHP
===========

[](#suncalc-php)

[![Tests](https://github.com/tuxonice/suncalc-php/actions/workflows/tests.yml/badge.svg)](https://github.com/tuxonice/suncalc-php/actions/workflows/tests.yml)[![Latest Version](https://camo.githubusercontent.com/b0f64ba1c790793cfa9ebb8978d75a026e3dd66f54a16f476f05393d1bb6d063/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7475786f6e6963652f73756e63616c632d7068702e737667)](https://packagist.org/packages/tuxonice/suncalc-php)[![PHP Version](https://camo.githubusercontent.com/2b8a050716359cc399072cc1af89efeb4ec9990ec9e3f8f807e0fc6dcf98ac2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7475786f6e6963652f73756e63616c632d7068702e737667)](https://packagist.org/packages/tuxonice/suncalc-php)[![Total Downloads](https://camo.githubusercontent.com/a6e16a2422690d8d2c58e1c58e1983bfa7e50cbf10ee6fc230f083720e319668/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7475786f6e6963652f73756e63616c632d7068702e737667)](https://packagist.org/packages/tuxonice/suncalc-php)[![License](https://camo.githubusercontent.com/13e2f5803385a3b9d0b93b4a1bba984eb58f3396f223dd0ca8d9c44a8dddc136/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7475786f6e6963652f73756e63616c632d7068702e737667)](LICENSE)

SunCalc PHP is a tiny PHP library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position, and lunar phase for a given location and time. This fork brings the original [gregseth/suncalc-php](https://github.com/gregseth/suncalc-php)library up to PHP 8, publishes it as a modern Composer package, and keeps full API compatibility with the original JavaScript library created by [Vladimir Agafonkin](http://agafonkin.com/en) ([@mourner](https://github.com/mourner)).

Most calculations are based on the formulas given in the excellent Astronomy Answers articles about the [position of the sun](http://aa.quae.nl/en/reken/zonpositie.html) and [the planets](http://aa.quae.nl/en/reken/hemelpositie.html). You can read about the different twilight phases calculated by SunCalc in the [Twilight article on Wikipedia](http://en.wikipedia.org/wiki/Twilight).

Requirements
------------

[](#requirements)

- PHP ^8.0
- ext-date (enabled by default on most PHP installations)

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

[](#installation)

Install the package via Composer:

```
composer require tuxonice/suncalc-php
```

Once installed, the library is available under the `Tlab\\SunCalc` namespace via PSR-4 autoloading.

Usage example
-------------

[](#usage-example)

```
