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

yipeiwu_com6年前PHP代码库

本文实例讲述了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>
<?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);
?>
</body>
</html>

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

相关文章

php判断当前操作系统类型

如何使用php获取当前操作系统类型呢?严格来说这里分两种情况,一种情况是获取服务器端的操作系统类型,一种是获取客户端的操作系统类型。下面作者将对如何使用php获取这两种情况下的操作系统类...

基于PHP编程注意事项的小结

 1、php隐性的三元操作符(?:)优先级问题: 例1:复制代码 代码如下:    $person = $who or $person = "la...

php断点续传之如何分割合并文件

复制代码 代码如下: <?php ini_set("memory_limit", "50M");//必须的,根据你环境的实际情况尽量大,防止报错 ini_set("max_exec...

PHP获取url的函数代码

复制代码 代码如下: function geturl($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_...

php使用curl伪造来源ip和refer的方法示例

本文实例讲述了php使用curl伪造来源ip和refer的方法。分享给大家供大家参考,具体如下: php curl伪造来源ip和来路refer实例代码1: //随机IP functi...