PHPackages                             spatie/sun - 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. spatie/sun

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

spatie/sun
==========

Get information on the position of the sun

1.1.5(5mo ago)73165.5k—9%142MITPHPPHP ^8.3CI passing

Since Apr 23Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/spatie/sun)[ Packagist](https://packagist.org/packages/spatie/sun)[ Docs](https://github.com/spatie/sun)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-sun/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (11)Used By (2)

Get information on the position of the sun
==========================================

[](#get-information-on-the-position-of-the-sun)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7c476d7f109f56bc4766be1c3d39dd44e3f6f4937168e9e37bffa1e3138bae90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f73756e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/sun)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5c5877f858c6a5e4a7193d34252fffeb1f784e8b7799f4758dce4d1b8b2a7366/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f73756e2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spatie/sun/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/ab0ee5a1ba0a442ad802962fa05248e2e6cf4acc094d3e836238b7edc9eede9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f73756e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/sun)

This package can determine several things on the position of the sun.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/10853a9fc6cccf96c6de120208743ba35a068a0ab67df831d7570d63b1341cfb/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f73756e2e6a70673f743d31)](https://spatie.be/github-ad-click/sun)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/sun
```

Usage
-----

[](#usage)

When instantiating `Spatie\Sun\Sun` you should pass it coordinates.

```
$coordinatesOfAntwerp = ['lat' => 51.260197, 'lng' => 4.402771];

$sun = new Sun($coordinatesOfAntwerp['lat'], $coordinatesOfAntwerp['lng']);
```

### Get the time of sunrise

[](#get-the-time-of-sunrise)

You can get the time of the sunrise.

```
$sun->sunrise(); // returns an instance of \Carbon\Carbon
```

You can get the time of the sunrise on a specific date by passing in instance of `Carbon\Carbon` to `sunrise`

```
$sun->sunrise($carbon); // returns an instance of \Carbon\Carbon
```

### Get the time of zenith

[](#get-the-time-of-zenith)

You can get the time of the zenith.

```
$sun->zenith(); // returns an instance of \Carbon\Carbon
```

You can get the time of the zenith on a specific date by passing in instance of `Carbon\Carbon` to `zenith`

```
$sun->zenith($carbon); // returns an instance of \Carbon\Carbon
```

### Get the time of sunset

[](#get-the-time-of-sunset)

You can get the time of the sunset.

```
$sun->sunset(); // returns an instance of \Carbon\Carbon
```

You can get the time of the sunset on a specific date by passing in instance of `Carbon\Carbon` to `sunset`

```
$sun->sunset($carbon); // returns an instance of \Carbon\Carbon
```

### Determine if the sun is up

[](#determine-if-the-sun-is-up)

This is how you can determine if the sun is up:

```
$sun->sunIsUp(); // returns a boolean
```

You can get determine if the sun is up at a specific moment by passing in instance of `Carbon\Carbon` to `sunIsUp`

```
$sun->sunIsUp($carbon); // returns a boolean
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance70

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 64.1% 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.

###  Release Activity

Cadence

Every ~227 days

Recently: every ~452 days

Total

10

Last Release

175d ago

PHP version history (3 changes)1.0.0PHP ^7.4

1.1.1PHP ^8.0|^7.4

1.1.3PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (50 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (7 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (5 commits)")[![Lukasss93](https://avatars.githubusercontent.com/u/4071613?v=4)](https://github.com/Lukasss93 "Lukasss93 (5 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (4 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![willemvb](https://avatars.githubusercontent.com/u/1336390?v=4)](https://github.com/willemvb "willemvb (1 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (1 commits)")[![MasterOdin](https://avatars.githubusercontent.com/u/1845314?v=4)](https://github.com/MasterOdin "MasterOdin (1 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (1 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")

---

Tags

geophpsunspatiesun

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/spatie-sun/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-sun/health.svg)](https://phpackages.com/packages/spatie-sun)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[spatie/laravel-schedule-monitor

Monitor scheduled tasks in a Laravel app

9815.7M9](/packages/spatie-laravel-schedule-monitor)[spatie/laravel-google-calendar

Manage events on a Google Calendar

1.4k1.5M21](/packages/spatie-laravel-google-calendar)[spatie/ssl-certificate

A class to easily query the properties of an ssl certificate

7414.8M35](/packages/spatie-ssl-certificate)[spatie/laravel-personal-data-export

Create personal data downloads in a Laravel app

550543.8k8](/packages/spatie-laravel-personal-data-export)[spatie/laravel-directory-cleanup

This package will remove the expired files from the given directories.

3061.4M6](/packages/spatie-laravel-directory-cleanup)

PHPackages © 2026

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