码迷,mamicode.com
首页 > Web开发 > 详细

PHP获取某一年所有的周六日期

时间:2015-05-30 01:58:36      阅读:673      评论:0      收藏:0      [点我收藏+]

标签:php   date   

直接贴代码:

<?php
$first_Sat=date(‘Y-m-d‘,strtotime(‘this Saturday‘,strtotime("2015-01-01")));
$Sat=array($first_Sat);
for($i=0;;$i+=7){
    $current_time=strtotime($i.‘ days‘,strtotime($first_Sat));
    if($current_time>strtotime(‘2015-12-31‘)){
        break;
    }
    $Sat[]=date(‘Y-m-d‘,$current_time);
}
var_dump($Sat);

代码书写格式,以及效率方面,自己去优化

本文出自 “随网互联” 博客,请务必保留此出处http://suiwnet.blog.51cto.com/2492370/1656486

PHP获取某一年所有的周六日期

标签:php   date   

原文地址:http://suiwnet.blog.51cto.com/2492370/1656486

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!