PHPackages                             langemike/php-store-hours - 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. langemike/php-store-hours

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

langemike/php-store-hours
=========================

Bringing php-store-hours into Laravel

0.3(8y ago)53.9k1MITPHPPHP &gt;=5.5.0

Since Jun 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/langemike/php-store-hours)[ Packagist](https://packagist.org/packages/langemike/php-store-hours)[ RSS](/packages/langemike-php-store-hours/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

PHP Store Hours for Laravel
===========================

[](#php-store-hours-for-laravel)

PHP Store Hours is a simple PHP class that outputs content based on time-of-day and-day-of-week. Simply include the script in any PHP page, adjust opening and closing hours for each day of the week and the script will output content based on the time ranges you specify.

### Easily set open hours for each day of the week

[](#easily-set-open-hours-for-each-day-of-the-week)

```
// REQUIRED
// Define daily open hours
// Must be in 24-hour format, separated by dash
// If closed for the day, leave blank (ex. sunday) or don't add line
// If open multiple times in one day, enter time ranges separated by a comma
$hours = array(
    'mon' => array('11:00-20:30'),
    'tue' => array('11:00-13:00', '18:00-20:30'),
    'wed' => array('11:00-20:30'),
    'thu' => array('11:00-1:30'), // Open late
    'fri' => array('11:00-20:30'),
    'sat' => array('11:00-20:00'),
    'sun' => array() // Closed all day
);
```

### Add exceptions for specific dates / holidays

[](#add-exceptions-for-specific-dates--holidays)

```
// OPTIONAL
// Add exceptions (great for holidays etc.)
// MUST be in format month/day[/year] or year-month-day
// Do not include the year if the exception repeats annually
$exceptions = array(
    '2/24'  => array('11:00-18:00'),
    '10/18' => array('11:00-16:00', '18:00-20:30')
);
```

### Customize the final output with shortcodes

[](#customize-the-final-output-with-shortcodes)

Choose what you'd like to output if you're currently open, currently closed, or closed all day. Shortcodes add dynamic times to your open or closed message.

```
// OPTIONAL
// Place HTML for output below. This is what will show in the browser.
// Use {%hours%} shortcode to add dynamic times to your open or closed message.
$template = array(
    'open'           => "Yes, we're open! Today's hours are {%hours%}.",
    'closed'         => "Sorry, we're closed. Today's hours are {%hours%}.",
    'closed_all_day' => "Sorry, we're closed today.",
    'separator'      => " - ",
    'join'           => " and ",
    'format'         => "g:ia", // options listed here: http://php.net/manual/en/function.date.php
    'hours'          => "{%open%}{%separator%}{%closed%}"
);
```

### Available Methods

[](#available-methods)

#### render(\[timestamp = time()\])

[](#rendertimestamp--time)

This is the default method that outputs the templated content. You'll most likely want to use this.

```
$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->render();
```

#### hours\_overview(\[groupSameDays = false\])

[](#hours_overviewgroupsamedays--false)

This returns an array with a full list of open hours (for a week without exceptions). Days with same hours will be grouped.

```
$store_hours = new StoreHours($hours, $exceptions, $template);

echo '';
foreach ($store_hours->hours_overview() as $days => $hours) {
    echo '';
    echo '' . $days . '';
    echo '' . $hours . '';
    echo '';
}
echo '';
```

#### hours\_today(\[timestamp = time()\])

[](#hours_todaytimestamp--time)

This returns an array of the current day's hours.

```
$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->hours_today();
```

#### is\_open(\[timestamp = time()\])

[](#is_opentimestamp--time)

This returns true/false depending on if the store is currently open.

```
$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->is_open();
```

### Use Cases

[](#use-cases)

#### Multiple stores / sets of hours

[](#multiple-stores--sets-of-hours)

If you'd like to show multiple sets of hours on the same page, simply invoke two separate instances of `StoreHours`. Remember to set the timezone before each new instance.

```
// New York Hours
date_default_timezone_set('America/New_York');
$nyc_store_hours = new StoreHours($nyc_hours, $nyc_exceptions, $nyc_template);
$nyc_store_hours->render();

// Los Angeles Hours
date_default_timezone_set('America/Los_Angeles');
$la_store_hours = new StoreHours($la_hours, $la_exceptions, $la_template);
$la_store_hours->render();
```

### Testing

[](#testing)

```
$ phpunit
```

### Troubleshooting

[](#troubleshooting)

If you're getting errors or if times are not rendering as expected, please double check these items before filing an issue on GitHub:

- Make sure your timezone is configured
- Ensure all exceptions use the month/day format
- Verify that StoreHours.class.php is properly included on the page

Please report any bugs or issues here on GitHub. I'd love to hear your ideas for improving this script or see how you've used it in your latest project.

Sites using PHP Store Hours
---------------------------

[](#sites-using-php-store-hours)

- [Des Plaines Public Library](http://dppl.org/)
- [The Nevada Discovery Museum](http://www.nvdm.org/)
- [Minne's Diner](http://www.minnesdiner.com/)
- Want to showcase your site? Tweet [@coryetzkorn](http://twitter.com/coryetzkorn)

### Credits

[](#credits)

Goes to [Cory Etzkorn](https://github.com/coryetzkorn/php-store-hours) for developing php-store-hours

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.5% 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 ~310 days

Total

3

Last Release

3053d ago

### Community

Maintainers

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

---

Top Contributors

[![coryetzkorn](https://avatars.githubusercontent.com/u/852079?v=4)](https://github.com/coryetzkorn "coryetzkorn (27 commits)")[![bartvandiepen1](https://avatars.githubusercontent.com/u/83601284?v=4)](https://github.com/bartvandiepen1 "bartvandiepen1 (6 commits)")[![mermshaus](https://avatars.githubusercontent.com/u/29676?v=4)](https://github.com/mermshaus "mermshaus (3 commits)")[![langemike](https://avatars.githubusercontent.com/u/1019129?v=4)](https://github.com/langemike "langemike (2 commits)")[![crookedneighbor](https://avatars.githubusercontent.com/u/2916945?v=4)](https://github.com/crookedneighbor "crookedneighbor (1 commits)")[![tibbi](https://avatars.githubusercontent.com/u/528931?v=4)](https://github.com/tibbi "tibbi (1 commits)")

---

Tags

laravelstorehoursopeningtimes

### Embed Badge

![Health badge](/badges/langemike-php-store-hours/health.svg)

```
[![Health](https://phpackages.com/badges/langemike-php-store-hours/health.svg)](https://phpackages.com/packages/langemike-php-store-hours)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20618.8k](/packages/stephenjude-filament-blog)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11258.1k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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