Weave 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
Laravel Hours Helper

Laravel Hours Helper Laravel Package

label84/laravel-hours-helper

Generate an Illuminate\Support\Collection of dates and times at a set interval for a given period—ideal for calendar dropdowns, meeting invites, and event scheduling. Supports custom formatting, excluded intervals, past-midnight ranges, and multi-day spans.

View on GitHub
Deep Wiki
Context7

Creates a Collection of times with a given interval.

Frequently asked questions about Laravel Hours Helper
How do I install laravel-hours-helper?
Install it with composer require label84/laravel-hours-helper. Laravel package auto-discovery registers the HoursHelper facade, and there is no config file to publish, no migrations, and no environment variables to set. It requires PHP 8.2+ and runs on Laravel 11, 12, or 13.
Which Laravel versions does laravel-hours-helper support?
Version ^1.4 supports Laravel 11.x, 12.x, and 13.x. The package tracks new Laravel releases via the laravel-shift bot, so Laravel 13 support shipped alongside 12 and 11 rather than lagging behind. Pin to ^1.4 to stay on the current supported line.
How do I generate time slots at a 30-minute interval in Laravel?
Call HoursHelper::create('08:00', '09:30', 30) and you get a Collection containing 08:00, 08:30, 09:00, and 09:30. The three positional arguments are start time, end time, and interval in minutes. The result is an Illuminate\Support\Collection, so map, filter, all(), and toArray() all work as expected.
How do I change the time format of the generated collection?
Pass a date format string as the fourth argument. For example, HoursHelper::create('11:00', '13:00', 60, 'g:i A') returns 11:00 AM, 12:00 PM, and 1:00 PM. Use formats like 'Y-m-d H:i' when generating multi-day ranges so each value carries its date.
Can I exclude certain times from the generated hours?
Yes. Pass an array of ranges as the fifth argument, such as [['09:00', '09:59']], and those intervals are dropped from the result. Exclusions are string-range matches against the generated, formatted output, so the ranges you supply must use the same format as your results. That coupling is subtle, so document it before wiring exclusions to database-driven values.
Does laravel-hours-helper handle overnight or past-midnight ranges?
Yes. HoursHelper::create('23:00', '01:00', 60) correctly rolls past midnight and returns 23:00, 00:00, and 01:00. Multi-day spans also work when you pass full date-times such as '2022-01-01 08:00' to '2022-01-02 08:00'. These are exactly the two cases where hand-rolled Carbon loops tend to break.
Does laravel-hours-helper support timezones and DST?
No. The package generates and formats strings and has no concept of timezones, DST transitions, availability, or booking conflicts. If your app serves users in multiple timezones, keep conversion and conflict logic in your application layer or a thin wrapper. HoursHelper only produces the candidate slot grid.
How do I use HoursHelper with Laravel validation rules?
Because the output is a plain Collection, you can pass it directly into Rule::in: Rule::in(HoursHelper::create('09:00', '17:00', 30)->all()). That keeps your form request validation and your dropdown options generated from a single source of truth. It also composes cleanly with Blade @foreach loops, API resources, and JSON responses.
Is laravel-hours-helper safe to use in production?
It is MIT licensed, has roughly 277 GitHub stars, and is a small leaf dependency with a low blast radius — no middleware, no Eloquent hooks, and no request lifecycle changes. The notable risks are the single-maintainer bus factor, which is cheap to mitigate by forking or vendoring, and in-memory generation, so chunk or cache monthly and yearly grids. Missing timezone awareness and format-coupled exclusions are application-side responsibilities rather than defects.
What are alternatives to laravel-hours-helper for scheduling in Laravel?
For simple slot generation, a hand-written Carbon loop or this helper both work; the helper just removes the loop and formatting code. If you need opening-hours semantics, conflict detection, or availability across timezones, use a scheduling engine instead — HoursHelper only covers the candidate grid, roughly 20% of a real booking feature. Wrapping the facade in a small SlotGenerator class keeps call sites insulated if you later fork or replace it.
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.
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai