PHP date() 函式遇到的坑

weixin_33686714發表於2018-09-10

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

function vdbr(obj);
echo '
';
}

相關文章