Home  >  Article  >  Backend Development  >  PHP method to calculate the start and end dates of the week in which a specified date falls, php date_PHP tutorial

PHP method to calculate the start and end dates of the week in which a specified date falls, php date_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:01:03777browse

PHP’s method of calculating the start and end dates of the week on a specified date, php date

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:

<html>
<head>
<title>计算一周开始结束日期</title>
</head>
<body>
<form method="post" action="./index.html" enctype="utf-8">
<table>
 <tr><td>输入年份</td>
 <td><input name="year" type="text" maxlength="4" /></td>
 </tr>
 <tr><td>输入月份</td>
 <td><input name="month" type="text" maxlength="2" /></td>
 </tr>
 <tr><td>输入天</td>
 <td><input name="day" type="text" maxlength="2" /></td>
 </tr>
 <tr><td colspan="2"><input type="submit" value="计算" />
</td></tr>
</table>
</form>
<&#63;php
$time= $_POST[year].'-'.$_POST[month].'-'.$_POST[day].' 00:00:00';
echo('你输入的时间是:'.$time.'</br>');
$lastday=date("Y-m-d",strtotime("$time Sunday"));
echo('输入的时间星期第一天是:'.date("Y-m-d",strtotime("$lastday - 6 days")).'<br/>');
echo('输入的时间星期最后一天是:'.$lastday);
&#63;>
</body>
</html>

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/972632.htmlTechArticleHow PHP calculates the start and end dates of the week in which the specified date is located, php date This article describes the example of PHP calculating the specified date Method for starting and ending dates of the week. Share it with everyone...
Statement:
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