3

現在の週の最初と最後の日の日付を取得して表示するにはどうすればよいですか。

したがって、今週は次のように出力されます。

2012-05-14  -  2012-05-20

(今日は 2012 年 5 月 17 日です)

これはどのように簡単に行うことができますか?

4

1 に答える 1

10

strtotimeを使用してみてください

$first = date('Y-m-d',strtotime("last monday"));
$last = date('Y-m-d',strtotime("next sunday"));

他の例

strtotime('monday this week');
strtotime('sunday this week');
于 2012-05-17T11:23:59.497 に答える