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(7mo ago)75181.3k↓27.3%142MITPHPPHP ^8.3CI passing

Since Apr 23Pushed 1mo 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 2d 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://github.com/spatie/sun/actions/workflows/run-tests.yml/badge.svg)](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

62

—

FairBetter than 99% of packages

Maintenance81

Actively maintained with recent releases

Popularity48

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

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

221d 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 (51 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

[illuminate/support

The Illuminate Support package.

630113.0M41.3k](/packages/illuminate-support)[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.3k6.1M68](/packages/spatie-laravel-analytics)[spatie/laravel-schedule-monitor

Monitor scheduled tasks in a Laravel app

9946.5M17](/packages/spatie-laravel-schedule-monitor)[spatie/holidays

Calculate public holidays

402860.1k2](/packages/spatie-holidays)[spatie/ssl-certificate

A class to easily query the properties of an ssl certificate

7515.2M39](/packages/spatie-ssl-certificate)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

293952.6k33](/packages/craftcms-feed-me)

PHPackages © 2026

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