Array of previous weeks
- by azz0r
Hello,
I am trying to create an array of weeks for users to select to view stats week on week.
What I'm looking for is an array that has the timestamp of week start (monday 00.00 to sunday 11.59) that I can then use in MYSQL queries.
Has anyone got an code that might assist? I was thinking of doing something like:
$number_of_weeks = 4;
$week_array = array();
foreach ($number_of_weeks as $week) {
$number_of_weeks--;
$value = $number_of_weeks * 604800;
$StartOfLastWeek = 6 + date("w",mktime());
$week_array[$number_of_week]['start'] =
date('Y-m-d', strtotime("-$StartOfLastWeek day"), $value);
$week_array[$number_of_week]['end'] =
date('Y-m-d', strtotime("-$StartOfLastWeek day"), $value+ 604800);
}