Is there a better way to go about doing this:
I'm looking to create a array with the elements being every minute from a classStartTime to an classEndTime (stored as strings).
here's what i have so far:
$dateFormat = "Y-m-d H:i:s";
$now = date($dateFormat);
$today = date("Y-m-d");
$year = date("Y");
$month = date("m");
$date = date("d");
$classStartTime = $today . " 18:00:00";
$classEndTime = $today . " 20:45:00";
$curTime = $classStartTime;
$dt = strtotime($curTime);
$i = 0;
while ( $dt > strtotime($classEndTime) )
{
$timeArray[i] = $curTime; //add incrementing time string to array
$dt = strtotime($curTime); //convert incrementing time string to DateTime
$dt = $dt + 60; //add 1 minute to DateTime (60 seconds)
$curTime = date($dateFormat,$dt); //convert back to string
$i++; //increment index
}
soo, the page either times out or doesn't even load.
i've even converted the loop to "where ( i < 10 )..." and it does the same as above.
is there an easier way to increment a DateTime by minute, convert to a string, and then store in an array?
FYI, i'm working with PHP 5.2.9
-mark