How to choose yesterday's date?

Good time of day. I can't select records from a database yesterday. Selects, yesterday and today. Here is the date function

private function getDateRangeFromDate($type) {
 switch (strtolower($type)) {
 case "calendar_year": return date('Y-01-01');
break;
 case "calendar_month": return date('Y-m-01');
break;
 case "year": $time = strtotime("-365 days", time());
 return date("Y-m-d", $time);
break;
 case "month": $time = strtotime("-30 days", time());
 return date("Y-m-d", $time);
break;
 case "week" : $time = strtotime("-1 week", time());
 return date("Y-m-d", $time);
break;
 case "oneday": $time = strtotime("-1 days", time());
 return date("Y-m-d", $time);
 case "today": return date("Y-m-d 00:00:00"); 
break;
}
 return date("Y-m-d");
 }


Doesn't work:
case "oneday": $time = strtotime("-1 days", time());
 return date("Y-m-d", $time);
April 4th 20 at 13:25
2 answers
April 4th 20 at 13:27
break put
This is a return, not echo - elyse95 commented on April 4th 20 at 13:30
April 4th 20 at 13:29
For readability it is better in case to do the assignment the value of a variable and one return.
And, so, the word "-30 days" and "-1 month" - a different date.
The method returns all normal. And the query to the database you have written. In my opinion, it is necessary to dig there.

Find more questions by tags PHP