---
title: "Spans and durations — Opening Hours for Laravel | Roundly"
description: "List opening periods between two instants, test whole spans, and measure open or closed time in real elapsed seconds."
url: https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel/spans-and-durations
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Opening Hours for Laravel](https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel.md)

# Spans and durations

Span queries work on coalesced periods clipped to the span:

```php
$hours->openingPeriodsBetween($monday, $monday->addWeek());   // list<OpeningPeriod>, clipped
$hours->isOpenDuring($from, $to);                              // open for the whole span
$hours->isClosedDuring($from, $to);                            // not open at any moment
$hours->openSecondsBetween($monday, $monday->addWeek());       // real elapsed seconds
$hours->closedSecondsBetween($from, $to);
$hours->openDurationBetween($from, $to);                       // CarbonInterval
```

- isOpenDuring() is true only when one continuous run covers the whole span; isClosedDuring() is true when no moment of it is open.
- Durations are real elapsed time — a 00:00–24:00 day lasts 23 or 25 hours on clock-change days.
- openDurationBetween() returns a cascaded CarbonInterval.
- Spans longer than max\_query\_days throw QueryRangeTooLargeException, carrying requestedDays and maxDays — isOpenDuring() and isClosedDuring() included.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel.md)
