Given two DateTime objects as input, and an integer $N, I want to partition the time in between them into $N equal intervals and return an array of $N + 1 evenly-spaced DateTimes that begins with the first input DateTime and ends with the last input DateTime.

The straightforward way of doing this would seem to be to subtract the two DateTimes, divide the resultant interval by $N, multiply and add repeatedly. But it doesn't work because DateTime::Duration just can't handle that kind of math.

What's the right way to do this? And what would it take to make a class comparable to DateTime::Duration that represents an interval of time that can actually be manipulated in this manner?

jdb

Reply via email to