promo-code / format-store-hours
A helper to display store hours
v1.0.3
2022-01-10 16:56 UTC
Requires
- php: >=7.1.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-03-10 23:41:32 UTC
README
A library to handle store hours.
use \PromoCode\StoreHours\Hours; $hours = Hours::instance() // Default is Monday (1). // This is setting it to Sunday (7). ->setStartingDayOfWeek(7) // By default consecutive days that have the same open hours are combined. // Setting this option to false will turn that off so every day is separate. ->setCombineConsecutiveDaysWithSameHours(false) // This sets the time format universally. // You can also set start and end date formats individually. ->setTimeFormat('g:ia'); foreach ($this->hours as $h) { $hours->addHoursForDay( $h->opens, $h->closes, $h->day_of_week ); } return $hours->getFormattedHours();