Generating a 'Y-m-d' value for the start of the previous week
I have some code that calculates the date for the beginning of the previous week.
However, in MySQL, the date needs to be shifted back one day to grab the first day of the date.
date("Y-m-d", time() - (date('w') - 1) * (60 * 60 * 24))
Now, I have actually solved this problem.
But it's a kludge.
$array_date = explode('-', date("Y-m-d", time() - (date('w') - 1) * (60 * 60 * 24)));
$array_search['start'] = date('Y-m-d', mktime(0, 0, 0, $array_date, $array_date - 1, $array_date));
So this is more out of curiosity than anything else, I'd just like to know what would need to be done to the first code sample to add on that extra day at the beginning.
I've tried everything I can think of, so any solution would be much appreciated!