LoginSignup
0
0

More than 5 years have passed since last update.

2月がカレンダーに4行7列ですっぽりハマる年を求めるスクリプト

Posted at

2月1日が月曜日で かつ 28日までの(うるう年ではない) 年を探す

<?php
$year_list = array();
for ($y = 0; $y < 3000; $y++) {
    // 2月1日の曜日と うるう年かどうかを取得
    list($w, $L) = str_split(date('wL', strtotime("$y-2-1")));
    if (!$L && $w == 0) {
        $year_list[] = $y;
    }
}
echo implode(', ', $year_list);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0