Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sun Laravel Package

spatie/sun

Compute sun position times for any coordinates: get sunrise, solar noon (zenith), and sunset as Carbon instances, optionally for a specific date. Simple PHP API from Spatie, ideal for scheduling, dashboards, and daylight-aware features.

View on GitHub
Deep Wiki
Context7

Get information on the position of the sun

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

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. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/sun

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

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

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

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

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport