Home >Backend Development >PHP Tutorial >PHP计算指定日期所在周的开始和结束日期的方法_php技巧

PHP计算指定日期所在周的开始和结束日期的方法_php技巧

WBOY
WBOYOriginal
2016-05-16 20:19:381070browse

本文实例讲述了PHP计算指定日期所在周的开始和结束日期的方法。分享给大家供大家参考。具体实现方法如下:

<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>

希望本文所述对大家的php程序设计有所帮助。

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