I have a start date as current date, which is stored in an array and the date 5 days back which is the end date.
Suppose the start date is 2014-12-03 and end date is 2014-11-28, so I have to print the count of a variable resulting from foreach, $value->user_source_history_date
And the process should run till the defined number lets say 30, where there are 30 dates in an array.
for($i=0; $i<=30; $i++)
{
$temp = strtotime("-5 days")
$dates = date("Y-m-d" , $temp)
}
Here I am iterating through 30 days, to get blocks of 5 days.
Lets say from a start date and end date, in the database field, user_source_history_dates, there are some 10 entries. So I need that count i.e 10 And the entries look like this:
2014-12-02 16:07:42
2014-12-02 16:07:42
2014-12-02 16:07:42
2014-12-02 16:07:42
2014-11-29 13:22:31
2014-11-29 13:22:31
2014-11-29 13:22:31
The start date would be 2014-12-03 and the end date would be 2014-11-28. So from the data above, I should get the count as 7.
My problem is how should I increment the count of $value->user_source_history_date
Also one of the problem is when the loop iterates, the end date previous iteration should become start date of next iteration.
One thing that I can do is use SQL query to get the data from a particular date block. Say something like this:
SELECT * FROM events WHERE datum BETWEEN '2011-4-6' AND '2011-4-12';