This article mainly shares with you the PHP implementation of getting the start date and end date of this week. It is mainly shared with you in the form of code. I hope it can help everyone.
<?php //当前日期 $sdefaultDate = date("Y-m-d"); //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $first=1; //获取当前周的第几天 周日是 0 周一到周六是 1 - 6 $w=date('w',strtotime($sdefaultDate)); //获取本周开始日期,如果$w是0,则表示周日,减去 6 天 $week_start=date('Y-m-d',strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days')); //本周结束日期 $week_end=date('Y-m-d',strtotime("$week_start +6 days")); echo "$week_start"."$week_end";
Related recommendations:
php method to get the start date and end date of this week, php start date_PHP tutorial
The above is the detailed content of PHP implementation to get the start date and end date of this week. For more information, please follow other related articles on the PHP Chinese website!