PHP code example of srtfisher / time-iterator
1. Go to this page and download the library: Download srtfisher/time-iterator 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/ */
srtfisher / time-iterator example snippets
use Srtfisher\TimeIterator;
$iterate = new TimeIterator;
// Set the Start date for five months ago
$iterate->setStart(60*60*24*7*5);
// Set the Interval to go over as 24 hours
$iterate->setInterval(60*60*24);
$iterate->setCallback(function(Carbon $start, Carbon $end, TimeIterator $object) {
// Perform some logic here
$object->addResults(array(
'data' => true,
// ....
));
});
// Run it
$iterate->run();
// Now, you can treat the object as an array
foreach ($iterate as $key => $data) {
// Do something with the data...
}