php strtotime 运用

var_dump(date("Y-m-d", strtotime("-1 month", strtotime("2018-10-15"))));
//'2018-09-15'
var_dump(date("Y-m-d", strtotime("-1 month", strtotime("2018-10-31"))));

//'2018-10-01'
var_dump(date("Y-m-d", strtotime("-1 month")));
//'2018-09-15'

var_dump(date("Y-m-d", strtotime("first day of -1 month", strtotime("2018-10-31"))));
//2018-09-01
 

posted on 2018-10-15 14:26  ph||py  阅读(350)  评论(0)    收藏  举报