How can PHP's date() function be used to get the date of the last 5 days?
To get the date of the last 5 days using PHP's date() function, you can use the strtotime() function to calculate the timestamp of 5 days ago and then format it using the date() function. This will give you the date of the last 5 days in the desired format.
$last5Days = date('Y-m-d', strtotime('-5 days'));
echo $last5Days;
Keywords
Related Questions
- How can online tools like https://3v4l.org/ help in testing PHP code?
- How can sandboxing and process control be implemented in PHP scripts to ensure robustness and fault tolerance in handling external components?
- What are the recommended methods for optimizing and improving the performance of PHP scripts that handle large amounts of data or user interactions?