phpで第2土曜日を取得するには、
<?php
echo date("Y年 n月j日", strtotime('second sat of this month'));
?>
で, 2015年 5月16日 と出力される。
これで次の第2土曜日を得る関数ができた。
next_2_sat_day.php
function next_2_sat_gatu_hi(){
if ( intval(date("Ymd")) <= intval(date("Ymd", strtotime('second sat of this month')))) {
return date("Y年 n月j日", strtotime('second sat of this month'));
} else {
return date("Y年 n月j日", strtotime('second sat of next month'));
}
}
echo next_2_sat_gatu_hi();
呼び出し結果、2015年 5月26日に実行すると
2015年 6月13日
となる。
参考にしたサイト:
http://php.net/manual/ja/datetime.formats.relative.php
http://php.net/manual/ja/function.date.php