PHP code example of promo-code / format-store-hours
1. Go to this page and download the library: Download promo-code/format-store-hours library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
promo-code / format-store-hours example snippets
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();