The DateTime
class makes working with dates like this much simpler and less prone to mistakes. The following should yield the desired results:
# Your start and end dates
$dates=(object)array(
'start' => '1/1/2015 10:00:00 AM',
'end' => '1/30/2015 5:00:00 PM'
);
# The input and output format for all dates used
$format='n/j/Y g:i:s A';
#create the start and end datetime objects and an interval of 1day ( 'P1D' )
$start=DateTime::createFromFormat( $format, $dates->start );
$end=DateTime::createFromFormat( $format, $dates->end );
$interval=new DateInterval('P1D');
$atArr = [];
# simple loop that adds the interval until it reaches the end date
while( $start < $end ){
$atArr[]=$start->format( $format );
$start->add( $interval );
}
printf('<pre>%s</pre>',print_r($atArr,true));
The result:
Array
(
[0] => 1/1/2015 10:00:00 AM
[1] => 1/2/2015 10:00:00 AM
[2] => 1/3/2015 10:00:00 AM
[3] => 1/4/2015 10:00:00 AM
[4] => 1/5/2015 10:00:00 AM
[5] => 1/6/2015 10:00:00 AM
[6] => 1/7/2015 10:00:00 AM
[7] => 1/8/2015 10:00:00 AM
[8] => 1/9/2015 10:00:00 AM
[9] => 1/10/2015 10:00:00 AM
[10] => 1/11/2015 10:00:00 AM
[11] => 1/12/2015 10:00:00 AM
[12] => 1/13/2015 10:00:00 AM
[13] => 1/14/2015 10:00:00 AM
[14] => 1/15/2015 10:00:00 AM
[15] => 1/16/2015 10:00:00 AM
[16] => 1/17/2015 10:00:00 AM
[17] => 1/18/2015 10:00:00 AM
[18] => 1/19/2015 10:00:00 AM
[19] => 1/20/2015 10:00:00 AM
[20] => 1/21/2015 10:00:00 AM
[21] => 1/22/2015 10:00:00 AM
[22] => 1/23/2015 10:00:00 AM
[23] => 1/24/2015 10:00:00 AM
[24] => 1/25/2015 10:00:00 AM
[25] => 1/26/2015 10:00:00 AM
[26] => 1/27/2015 10:00:00 AM
[27] => 1/28/2015 10:00:00 AM
[28] => 1/29/2015 10:00:00 AM
[29] => 1/30/2015 10:00:00 AM
)