date('Y-m-d', strtotime("last Monday"))
現在の月曜日を表示します。最後の月曜日は月曜日です
どのように私は日付の例のためにこれを確認することができます。
2010-11-12と2011-03-04?
date('Y-m-d', strtotime("last Monday"))
現在の月曜日を表示します。最後の月曜日は月曜日です
どのように私は日付の例のためにこれを確認することができます。
2010-11-12と2011-03-04?
私はDateTime
クラスを使用します。
$dateTime = new DateTime('2010-11-12');
$dateTime->modify('last Monday');
echo $dateTime->format('Y-m-d');
DateTime
クラスas already answeredを使用するか、もう一度だけstrtotime
Docsを使用します。
echo date('Y-m-d', strtotime("last Monday", strtotime("2010-11-12")));
以上にきれいに並ん:
$date = strtotime("2010-11-12");
echo date('Y-m-d', strtotime("last Monday", $date));
のstrtotime関数は二通りのUNIXタイムスタンプを取ることができますが相対的な計算の今の時間として使用するための入力。ドキュメントを参照してくださいhere