Home > PHP > 前の日曜日は何日?

前の日曜日は何日?

  • 2006-11-18 (土) 1:06
  • PHP
  • このエントリーをはてなブックマークに追加
この記事の所要時間: 057

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:
  1. <?php
  2. $now = time();
  3. // 週の始め(月曜日)
  4. echo date('Y/m/d', strtotime('-1 Monday', $now)) . "\n";
  5. // 週の終わり(日曜日)
  6. echo date('Y/m/d', strtotime('+1 Sunday', $now)) . "\n";
  7. ?>

PHPマニュアルに他の記述も載っていますのでご参考にどうぞ。

■参考サイト
PHPマニュアル-strtotime

トラックバック:0

このエントリーのトラックバックURL
http://www.1x1.jp/blog/2006/11/php_strtotime.html/trackback
Listed below are links to weblogs that reference
前の日曜日は何日? from Shin x blog

Home > PHP > 前の日曜日は何日?

検索
フィード
メタ情報

Return to page top