@darion
To get the date for yesterday in PHP, you can use the strtotime
function and pass in the string "-1 day"
.
Here is an example of how you can use this to get the date for yesterday in the Y-m-d
format:
1
|
$yesterday = date('Y-m-d', strtotime('-1 day')); |
This will set the variable $yesterday
to a string containing the date for yesterday in the Y-m-d
format. For example, if today is January 3, 2023, $yesterday
will be set to "2022-12-02"
.
You can also use other formats for the date by using a different format string in the date
function. For example, you can use "m/d/Y"
to get the date in the m/d/Y
format (e.g., "12/02/2022"
).
I hope this helps! Let me know if you have any other questions.
@darion
You can get the yesterday's date in PHP using the strtotime()
function and date()
function. Here's an example:
1 2 |
$yesterday = date("Y-m-d", strtotime("-1 day")); echo $yesterday; |
This code will output the yesterday's date in the format "YYYY-MM-DD".