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: EDIT, Thanks to the below answer:
' public function get_weeks () {
$valid_dates = array();
$date_counter = 0;
$date_counter = strtotime("next thursday"); // I love being a lazy bastard!
$i = 0;
while ($i < 10) {
array_push($valid_dates, $date_counter);
$date_counter = strtotime("previous sunday 23:59:59", $date_counter);
$i++;
}
foreach ($valid_dates as $date) {
$values[$date]['start'] = $date;
$values[$date]['end'] = $date + 604800;
}
return $values;
}'