PHP獲取某一年全部的週六日期

直接貼代碼:php

<?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);

代碼書寫格式,以及效率方面,本身去優化
ide

相關文章
相關標籤/搜索