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
$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

Pocket

follow us in feedly

トラックバック:0

このエントリーのトラックバックURL
/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