Laravel-hours-helper - Creates a Collection of times with a given interval.

Overview

Laravel Hours Helper

Latest Stable Version MIT Licensed Quality Score Total Downloads

With laravel-hours-helper you can create a collection of dates and/of times with a specific interval (in minutes) for a specific period. You can also exclude multiple dates/times from the collection.

Requirements

  • Laravel 8.x

Laravel support

Version Release
8.x 1.0

Installation

Install the package via composer:

composer require label84/laravel-hours-helper

📝 Prepend the import with Facades\ to the make use of the real-time Facade.

Usage

use Facades\Label84\HoursHelper\HoursHelper;

$hours = HoursHelper::create('08:00', '09:30', 30);

// collection result
0 => '08:00',
1 => '08:30',
2 => '09:00',
3 => '09:30',

Example 1: time format

use Facades\Label84\HoursHelper\HoursHelper;

$hours = HoursHelper::create('11:00', '13:00', 60, 'g:i A');

// collection result
0 => '11:00 AM',
1 => '12:00 PM',
2 => '1:00 PM',

Example 2: exclude times

use Facades\Label84\HoursHelper\HoursHelper;

$hours = HoursHelper::create('08:00', '10:00', 60, 'H:i', [
    ['09:00', '09:59'],
    // more..
]);

// collection result
0 => '08:00',
1 => '10:00',

Example 3: past midnight

use Facades\Label84\HoursHelper\HoursHelper;

$hours = HoursHelper::create('23:00', '01:00', 60);

// collection result
0 => '23:00',
1 => '00:00',
2 => '01:00',

Example 4: multiple days

$hours = HoursHelper::create('2022-01-01 08:00', '2022-01-01 08:30', 15, 'Y-m-d H:i');

// collection result
0 => '2022-01-01 08:00',
1 => '2022-01-01 08:15',
2 => '2022-01-01 08:30',

You can find more examples in the test directory: tests/HoursHelperTest.php

Tests

./vendor/bin/phpstan analyze
./vendor/bin/phpunit

License

MIT

You might also like...
Creates Packagist.org mirror site.

Packagist Mirror Creates your own packagist.org mirror site. Requirements PHP ^7.1.3 Installation Clone the repository Install dependencies: php compo

PHPench creates a graphical output for a PHP benchmark
PHPench creates a graphical output for a PHP benchmark

PHPench creates a graphical output for a PHP benchmark. Plot the runtime of any function in realtime with GnuPlot and create an image out of the result.

Webman quickly creates a verification code tool similar to Google verification code
Webman quickly creates a verification code tool similar to Google verification code

webman-captcha-grid webman quickly creates a verification code tool similar to Google verification code webman 快速创建一个类似于 Google 点图验证码的本地验证码扩展 介绍 webma

A collection of open source projects built using Laravel.

Open Laravel A repository of open source projects built using Laravel. Getting Started Clone the project repository by running the command below if yo

Mirror Laravel model inside Firestore collection.

Laravel Firestore Mirror This package can be used to store copy of Laravel model inside Firestore collection. Installation Install package: composer r

Helper for countries laravel package

Countries helper Helper for countries laravel package Installation You can install the package via composer: composer require eliseekn/countries-helpe

PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule for validation Japanese string only full-width or only half-width.

Japanese String Helpers PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule f

An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.
An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.

OrchidTables An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods. In

Simple opinionated PHP 8.1 enum helper for Laravel
Simple opinionated PHP 8.1 enum helper for Laravel

Laravel Enum Helper This is an extension of the datomatic/enum-helper package based on Laravel Framework. The package consists on a LaravelEnumHelper

Comments
  • Updated map to use higher order messages

    Updated map to use higher order messages

    You don't need to pass the callback to map in Laravel. You can simply pass the format to map as the returned type is already of Carbon.

    All tests pass still.

    opened by dantaylorseo 1
Releases(v1.2.0)
Owner
Label84
Label84
This car rental project system project in PHP focuses mainly on dealing with customers regarding their car rental hours and certain transactions.

Car-Rental Online Car Rental Management System This car rental project system project in PHP focuses mainly on dealing with customers regarding their

Adarsh Kumar Singh 2 Sep 29, 2022
Makes indexing of your Magento store around x times faster! ‼️ Maintainers wanted!

FastIndexer This module has never been used in production. No more empty results in the frontend due to a long taking reindex process! Integrates seam

Cyrill Schumacher 79 Jul 10, 2022
Increase "Death by 1000 needles" attack up to 100x times

Підсили свою атаку у 100 разів разом із db1000nX100 db1000nX100 це Linux контейнер для популярної програми db1000n, щo дозволяє значно підняти ефектив

null 62 Dec 31, 2022
A Magento implementation for validating JSON Structures against a given Schema

Zepgram JsonSchema A Magento implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Base

Benjamin Calef 1 Nov 5, 2021
Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

LimeSoda Interactive Marketing GmbH 73 Apr 1, 2022
Enabling community-powered extension and improvements of the best time indications given.

Enabling community-powered extension and improvements of the best time indications given.

Digital Markethingz 2 Jun 29, 2022
Applies a patch from a local or remote file to any package that is part of a given composer project.

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level in package config or separate JSON file. Declaration-free mode (using embedded info within patch files) is available as well.

Vaimo 245 Dec 15, 2022
Creates a WorldBorder for PocketMine-MP servers!

This plugin is not yet ready for Poggit or download It is going through mass changes over the next few days Message my Discord to recieve an older eli

Soulz 9 Sep 5, 2021
Analyzes PHPStan baseline files and creates aggregated error trend-reports

Analyzes phpstan baseline files Analyzes PHPStan baseline files and creates aggregated error trend-reports.

Markus Staab 22 Dec 23, 2022
A plugin that creates a level system linked to chatting for PocketMine-MP!

ChatLevel A plugin that creates a level system linked to chatting for PocketMine-MP! Issues You can report bugs by simply clicking me! Support You can

Oğuzhan 2 Oct 28, 2021