function next_ten_first_sat(){
$next_month = strtotime(date('Y-m-d'));
$j=0;
for($i=1;$i<10;$i++){
if($i==1){
$sat_next_month[$i] = strtotime('next month first saturday', $next_month);
$next_month = strtotime(date('Y-m',$sat_next_month[$i]).'-01');
}else{
$sat_next_month[$i] = strtotime('next month first saturday', $next_month);
$next_month = strtotime(date('Y-m',$sat_next_month[$i]).'-01');
$result_year = date('Y', $sat_next_month[$i]);
if(date('m', $sat_next_month[$i])>10){
$result_month = date('m', $sat_next_month[$i])-1;
}else{
$result_month = date('m', $sat_next_month[$i])-1;
$result_month = '0'.$result_month;
}
$result_date = date('d', $sat_next_month[$i]);
$result_array[$j] = $result_year.'-'.$result_month.'-'.$result_date;
}
$j++;
}
return $result_array;
}
申し訳ありませんが、みんな初めて質問を読み違えます。これは意図したとおりに動作するはずですが、非常に乱雑です...それらを最適化してください.....
'date( 'Ym-d'、strtotime( '2011年2月1日の土曜日));' – Mchl
エコーで何もしない –
奇妙なことに、ここで「2011年2月5日」とエコーします。とにかく、 'strtotime()'を探索し、それが受け入れるフォーマットをします。 – Mchl