[PHP] 翌日や1週間後、1ヶ月後の日付を求める方法

自由が丘で働くWeb屋のブログ

[PHP] 翌日や1週間後、1ヶ月後の日付を求める方法

[PHP] 翌日や1週間後、1ヶ月後の日付を求める方法
PHPを用いて明日や1週間後、1ヶ月後の日付を求める方法。
詳細は以下から。

翌日や1週間後、1ヶ月後の日付を求める方法

echo "今日  :".date('Y-m-d')."<br />\n";
echo "翌日  :".date('Y-m-d', strtotime('+1 day'))."<br />\n";
echo "1週間後:".date('Y-m-d', strtotime('+1 week'))."<br />\n";
echo "1ヵ月後:".date('Y-m-d', strtotime('+1 month'))."<br />\n";

任意の日付の翌日、1週間後、1ヶ月後を求めたい場合は下記の様に記述します。

//2013-08-01の翌日、1週間後、1ヶ月後を求めたい場合
$year = '2013';
$month ='08';
$day = '01';
$start_date = mktime(0,0,0,$month, $day, $year);

echo "翌日  :".date('Y-m-d', strtotime('+1 day', $start_date))."<br />\n";
echo "1週間後:".date('Y-m-d', strtotime('+1 week', $start_date))."<br />\n";
echo "1ヵ月後:".date('Y-m-d', strtotime('+1 month', $start_date))."<br />\n";
 
カテゴリー:Webシステム開発
タグ:
2013年8月27日 16時27分
 

関連記事

 

コメントを書く

(C) 自由が丘で働くWeb屋のブログ