PHP date()関数に遭遇したピット

1283 ワード

vdbr(date("Y-m-d", strtotime("2017-06-31")));
//  2017-07-01
vdbr(date("Y-m-d", strtotime("-1 month", strtotime("2017-03-31"))));
//  2017-03-03
vdbr(date("Y-m-d", strtotime("+1 month", strtotime("2017-08-31"))));
//  2017-10-01
vdbr(date("Y-m-d", strtotime("next month", strtotime("2017-01-31"))));
//  2017-03-03
vdbr(date("Y-m-d", strtotime("last month", strtotime("2017-03-31"))));
//  2017-03-03

vdbr(date("Y-m-d", strtotime("last day of -1 month", strtotime("2017-03-31"))));
//  2017-02-28
vdbr(date("Y-m-d", strtotime("first day of +1 month", strtotime("2017-08-31"))));
////  2017-09-01
vdbr(date("Y-m-d", strtotime("first day of next month", strtotime("2017-01-31"))));
////  2017-02-01
vdbr(date("Y-m-d", strtotime("last day of last month", strtotime("2017-03-31"))));
////  2017-02-28
 echo "
:" . date('Y-m-d', strtotime('this week')); echo "
:" . date('Y-m-d', strtotime('last day next week +1 day')); function vdbr($obj) { var_dump($obj); echo '
'; }