strtotime
を使用して、指定された月の最初の水曜日を把握しようとしていますが、最初の水曜日が1日目に降りるたびに "最初の水曜日"strtotimeで月の最初の平日を取得
12/06/10
12/07/10
12/08/10
12/02/10
12/03/10
12/04/10
12/05/10
お知らせ何か:中
$mon = strtotime("December 2010 first monday");
$tue = strtotime("December 2010 first tuesday");
$wed = strtotime("December 2010 first wednesday");
$thu = strtotime("December 2010 first thursday");
$fri = strtotime("December 2010 first friday");
$sat = strtotime("December 2010 first saturday");
$sun = strtotime("December 2010 first sunday");
echo strftime("%m/%d/%y", $mon) . "<br>";
echo strftime("%m/%d/%y", $tue) . "<br>";
echo strftime("%m/%d/%y", $wed) . "<br>";
echo strftime("%m/%d/%y", $thu) . "<br>";
echo strftime("%m/%d/%y", $fri) . "<br>";
echo strftime("%m/%d/%y", $sat) . "<br>";
echo strftime("%m/%d/%y", $sun) . "<br>";
結果:この問題のより一般的な説明のため
は、次のコードと結果を参照してください?月の1日と1週間の1日が一致してはいけませんか?しかし、それは決してしません。代わりに、8日には、その日の2番目のインスタンスが常に返されます。
誰でも説明がありますか?
確かに、これは動作します。理由を聞かないようにしましょう... – Yarin
がの場合、私にとっては、本当に興味があります.D –
完全に動作していないようです。私は6月12日にこのソリューションを利用しています。私は '12/15/2014'を取得します。おそらくそれは現在の月の週に相対的ですか? – Webnet