How can PHP be used to calculate the current week minus one?
To calculate the current week minus one in PHP, you can use the `strtotime` function to get the timestamp for the current date and then use the `date` function to format the date of the previous week. By subtracting 7 days from the current date, you can get the date of the previous week.
$currentDate = strtotime('today');
$previousWeek = date('W', strtotime('-1 week', $currentDate));
echo "Current week minus one: " . $previousWeek;
Keywords
Related Questions
- What are the limitations of using MD5 encryption for password storage in PHP, and what alternative encryption methods can be considered?
- In what situations is it appropriate to prioritize functionality over cosmetic enhancements in PHP web development, especially when catering to a diverse user base with varying browser settings?
- How can PHP be used to populate form fields with current database values for user profiles?