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
 

猜你喜欢

转载自www.cnblogs.com/opzx/p/9790789.html
今日推荐