This package is abandoned and no longer maintained. No replacement package was suggested.

Simple helper to iterate over time

v1.0.0 2015-11-04 13:04 UTC

This package is auto-updated.

Last update: 2022-02-01 12:52:33 UTC


Simple helper to iterate over time:

foreach (TimeIterator::create('today', '+1 day', 'last day of this month') as $day) {
    echo 'Event created for date: ' . $day->format('Y-m-d') . PHP_EOL;

will output a list of dates from today until the end of the month. Simple, isn't it?

You can also fetch an array of DateTime objects using getArray():

$ti = new TimeIterator('now', '+1 minute', 'tomorrow');

Or if you just need an array of strings, you can just use format($format):

$ti = new TimeIterator('15:00', '-5 minutes', '14:30');
return $ti->format('H:i');

will return: