- 2006-11-18 (土) 1:06
- PHP
この記事の所要時間: 約 0分57秒
strtotime()で様々な日付をunixタイムスタンプで取得できます。
Keep it simple and just do strtotime(‘-1 Sunday’,$currentDay);
Calculating start and end dates of a week. – Derick Rethans (2006-11-18)
コメント欄からの引用です。
エントリにある週の始め、終わりの日にちを取得するには以下で取得できます。
< ?php
$now = time();
// 週の始め(月曜日)
echo date('Y/m/d', strtotime('-1 Monday', $now)) . "\n";
// 週の終わり(日曜日)
echo date('Y/m/d', strtotime('+1 Sunday', $now)) . "\n";
?>
PHPマニュアルに他の記述も載っていますのでご参考にどうぞ。
■参考サイト
PHPマニュアル-strtotime
トラックバック:0
- このエントリーのトラックバックURL
- /blog/2006/11/php_strtotime.html/trackback
- Listed below are links to weblogs that reference
- 前の日曜日は何日? from Shin x blog

