Get First Day of Current Week in PHP
Determining the first day of the current week is a common task when working with dates. In PHP, you can use a combination of date functions to achieve this:
Solution:
$day = date('w'); $week_start = date('m-d-Y', strtotime('-'.$day.' days'));
Here, $day represents the current day of the week, ranging from 0 (Sunday) to 6 (Saturday). By subtracting $day from the current date using strtotime(), we get the date of the previous Sunday, which is the first day of the current week.
The above is the detailed content of How to Get the First Day of the Current Week in PHP?. For more information, please follow other related articles on the PHP Chinese website!