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 -h可以获取帮助信息。PHP版本号信息:/your_current_path/php -v,PHP运行脚本:/your_current_path/php your_file_path,PHP运行语句/your_current_path/php -r your_code_snippet。
代码执行结束后,PHP会根据具体执行情况自动的释放,如果执行过程中内存消耗较大,可以利用NULL或unset来释放内存。区别在于,前者 ......
//转换为UNIX时间戳
function strtotimestamp(datestr)
{
var new_str = datestr.replace(/:/g,"-");
new_str = new_str.replace(/ /g,"-");
var arr = new_str.split("-");
var datum = new Date(Date. ......
AddSlashes: 字符串加入斜线。
bin2hex: 二进位转成十六进位。
Chop: 去除连续空白。
Chr: 返回序数值的字符。
chunk_split: 将字符串分成小段。
convert_cyr_string: 转换古斯拉夫字符串成其它字符串。
crypt: 将字符串用 DES 编码加密。
echo: 输出字符串。
explode: 切开字符串。
flush: 清出输出缓 ......
<?php
$url="这里写请求地址";//http://pmtest.webgame.com.cn/d.php
$data="这里写post数据";//如:a=123&b=456 表示传两个参数a和b
$rfr="发出数据的页面的地址";
$cookie="这里写cookie";//如:PHPSESSIDs=123456; b=11212
/*
例子:
$rfr="http://*.c ......