Home > php教程 > php手册 > body text

php 取出周一和周日的时间戳

WBOY
Release: 2016-06-13 10:59:11
Original
1469 people have browsed it

取出周一和周日的时间戳
能过下面两款取出周一和周日的时间戳实例可以看得出来很多的东西,要不断的思想哦,第一个自定的取出指定日期的时间戳比较好,但是如何是取出周一和周日第二个就更实用了。
*/

function getmonsun(){
    $curtime=time();
      
    $curweekday = date('w');

     //为0是 就是 星期七
    $curweekday = $curweekday?$curweekday:7;


    $curmon = $curtime - ($curweekday-1)*86400;
    $cursun = $curtime + (7 - $curweekday)*86400;
     
    $cur['mon'] = $curmon;
    $cur['sun'] = $cursun;

    return $cur;
}
    $cur = getmonsun();

    echo date('y-m-d',$cur['mon']);
    echo "rn";
    echo date('y-m-d',$cur['sun']);
 
//方法二 利用php strtotime函数

 echo strtotime('last monday');
 echo &#39;<br />&#39;;
 echo strtotime(&#39;next sunday&#39;);
Copy after login

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!