Home > Backend Development > PHP Tutorial > PHP method to calculate the start and end dates of the week in which the specified date falls_PHP Tutorial

PHP method to calculate the start and end dates of the week in which the specified date falls_PHP Tutorial

WBOY
Release: 2016-07-13 10:00:44
Original
1063 people have browsed it

PHP method to calculate the start and end date of the week on the specified date

This article mainly introduces the method of PHP to calculate the start and end date of the week on the specified date, involving PHP The skills of operating date and time have certain reference value. Friends in need can refer to it

The example in this article describes how PHP calculates the start and end dates of the week on a specified date. Share it with everyone for your reference. The specific implementation method is as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

计算一周开始结束日期

输入年份
输入月份
输入天

$time= $_POST[year].'-'.$_POST[month].'-'.$_POST[day].' 00:00:00';

echo('你输入的时间是:'.$time.'
');

$lastday=date("Y-m-d",strtotime("$time Sunday"));

echo('输入的时间星期第一天是:'.date("Y-m-d",strtotime("$lastday - 6 days")).'
');

echo('输入的时间星期最后一天是:'.$lastday);

?>

1 2

3

4 5

67 8 9 10 11 12
13
14
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Calculate the start and end dates of the week
Enter the year
Enter the month
Enter the day
<🎜>$time= $_POST[year].'-'.$_POST[month].'-'.$_POST[day].' 00:00:00';<🎜> <🎜>echo('The time you entered is: '.$time.'
'); $lastday=date("Y-m-d",strtotime("$time Sunday")); echo('The entered time and the first day of the week is:'.date("Y-m-d",strtotime("$lastday - 6 days")).'
'); echo('The last day of the week entered is: '.$lastday); ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/973119.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/973119.htmlTechArticleHow PHP calculates the start and end dates of the week where the specified date falls. This article mainly introduces the method of PHP calculating where the specified date falls. The method of starting and ending dates of the week involves php operating date and time...
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