Given a time, how can I find the time one month ago

后端 未结 7 1509
梦如初夏
梦如初夏 2021-01-13 08:16

Given a time, how can I find the time one month ago.

7条回答
  •  [愿得一人]
    2021-01-13 08:42

    This code is for getting 1 month before not 30 days

    $date = "2016-03-31";
    
    $days = date("t", strtotime($date));
    
    echo  date("Y-m-d", strtotime( "-$days days", strtotime($date) ));
    

提交回复
热议问题