development:language:php:tips:getdate
文書の過去の版を表示しています。
日付の取得
<?php // 本日の日付 echo date("Y/m/d"); // 今月末日 echo date("Y/m/t"); // 1日前 echo date("Y/m/d",strtotime("-1 day")); // 1週間前 echo date("Y/m/d",strtotime("-1 week")); // 1ヶ月前 echo date("Y/m/d",strtotime("-1 month")); // 来月末日 echo date("Y/m/t",strtotime("1 month")); // 1年前 echo date("Y/m/d",strtotime("-1 year")); // 1日後 echo date("Y/m/d",strtotime("+1 day")); // 3日前 echo date("Y/m/d",strtotime("-3 day")); // 次の日曜日 echo date("Y/m/d",strtotime("next Sunday")); // 次の次の日曜日 echo date("Y/m/d",strtotime("+2 Sunday")); // この前の日曜日 echo date("Y/m/d",strtotime("last Sunday")); // 先週の日曜日 echo date("Y/m/d",strtotime("2 weeks ago Sunday")); // 先週の土曜日 echo date("Y/m/d",strtotime("last Saturday")); //来月1日 echo date("Y/m/d",strtotime("first day of next month"));
※「この前の日曜日」と「先週の日曜日」は違うので注意
- echo date(“Y/m/d”);
- echo date(“Y/m/d H:i”);
- echo date(“Y/m/d H:i”, strtotime(“2010/9/8 6:05”));
development/language/php/tips/getdate.1625387485.txt.gz · 最終更新: 2021/07/04 08:31 by hayashi