php 取出周一和周日的时间戳
php 取出周一和周日的时间戳,能过下面两款取出周一和周日的时间戳实例可以看得出来很多的东西,要不断的思想哦,第一个自定的取出指定日期的时间戳比较好,但是如何是取出周一和周日第二个就更实用了.
方法一:
- 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 '<br />';
- echo strtotime('next sunday');