Wednesday, 14 August 2013

PHP time intervals

PHP time intervals

I'm looking for a solution to something which seems like it should be
pretty simple, but it doesn't seem that I can find any good answers on
here, and I can't seem to get it to work myself.
What I'm looking for is to set a start time, an end time, and then iterate
through a set of times between given a time interval. Say, for example,
9:00 AM - 5:00 PM are the start times, and the values returned between
these times at half hour intervals are 9:30, 10:00, 10:30, 11:00, etc.
Here's some pseudo-code, because I'm not exactly sure what I need to plug
in here (at least nothing I've tried has worked)...
for ($i = *start time*; $i = *end time*; $i += *time interval*) {
echo $i;
}
Any ideas on this?

No comments:

Post a Comment