PHP code example of gpaddis / timeslot
1. Go to this page and download the library: Download gpaddis/timeslot 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/ */
gpaddis / timeslot example snippets
// Create a 30-minutes timeslot from a string starting at 15:00
$timeslot = new Timeslot('2017-08-19 15:00:00', 0, 30);
// Get its start and end time as datetime strings (Carbon)
$timeslot->start()->toDateTimeString(); // 2017-08-19 15:00:00
$timeslot->end()->toDateTimeString(); // 2017-08-19 15:29:59
// Create a TimeslotCollection based on the $timeslot, containing 4 timeslots
$collection = TimeslotCollection::create($timeslot, 4);
// A TimeslotCollection has a start and end time as well...
$collection->start()->toDateTimeString(); // 2017-08-19 15:00:00
$collection->end()->toDateTimeString(); // 2017-08-19 16:59:59 (2 hours later)
// ...and you can get the single timeslots if you want.
$collection->get(1)->start()->toDateTimeString(); // 2017-08-19 15:30:00 (second timeslot in the collection)