Home > Backend Development > PHP Tutorial > How to get the start date and end date of this week in php, php start date_PHP tutorial

How to get the start date and end date of this week in php, php start date_PHP tutorial

WBOY
Release: 2016-07-13 10:04:31
Original
1317 people have browsed it

How to get the start date and end date of this week in php, php start date

The example in this article describes the method of getting the start date and end date of this week in php. Share it with everyone for your reference. The details are as follows:
Copy code The code is as follows: //current date
$sdefaultDate = date("Y-m-d");
//$first =1 means every Monday is the starting date, 0 means every Sunday is the starting date
$first=1;
//Get the day of the current week. Sunday is 0, Monday to Saturday is 1 - 6
$w=date('w',strtotime($sdefaultDate));
//Get the start date of this week. If $w is 0, it means Sunday, minus 6 days
$week_start=date('Y-m-d',strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days'));
//End date of this week
$week_end=date('Y-m-d',strtotime("$week_start +6 days"));

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/965351.htmlTechArticleHow to get the start date and end date of this week in php, php start date This article tells the example of getting the start of this week in php Date and end date methods. Share it with everyone for your reference. Specifically...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template