So I have 5 variables that I use to store last weeks dates using the php function strtotime()
The only problem is, every Sunday the dates return the same dates. Like today for instance, using $monday = date('Y-m-d', strtotime('monday last week')); will return me a date of 2019-04-08
Obviously being the 2019-04-21 today that should be 2019-04-08. The problem starts here though, if I use this $tuesday = date('Y-m-d', strtotime('tuesday last week')); it will return me a date of 2019-04-08 and the date today is 2019-04-21 so it should return return me the date 2019-04-09.
The same is true if I try any of the weekdays. They all return me the same date, 2019-04-08.
What's more is its also true if you are using date('Y-m-d', strtotime('monday this week'));
works for monday but returns monday for all of the days of the week when on a Sunday.
I saw someone say use a function, so I was researching on here and tried it but it returned the same result.
//// function I tried but it proved to produce the same results.///////
function lastfriday() {
return date('Y-m-d', date('N')==5 ? strtotime('today') : strtotime('last friday'));
}
////////// this is the code I have been using but as I explained, every Sunday it gets buggy
echo $monday = date( 'Y-m-d', strtotime( 'monday last week' ) );
echo $tuesday = date( 'Y-m-d', strtotime( 'tuesday last week' ) );
echo $wednesday = date( 'Y-m-d', strtotime( 'wednesday last week' ) );
echo $thursday = date( 'Y-m-d', strtotime( 'thursday last week' ) );
echo $friday = date( 'Y-m-d', strtotime( 'friday last week' ) );
echo $saturday = date( 'Y-m-d', strtotime( 'saturday last week' ) );
running that code on today 2019-04-21 produces the results
2019-04-08
2019-04-08
2019-04-08
2019-04-08
2019-04-08
2019-04-08