php獲取指定日期的前一天,前一月,前一年日期


前一天的日期為:

date("Y-m-d",strtotime("-1 days",strtotime('2019-08-31')))

 

前一月的日期為

date("Y-m-d",strtotime("-1 months",strtotime('2019-08-31')))

 

前一年的日期為:

date("Y-m-d",strtotime("-1 years",strtotime('2019-08-31')))

 

后一天的日期為:

date("Y-m-d",strtotime("+1 days",strtotime('2019-08-31')))

 

后一月的日期為:

date("Y-m-d",strtotime("+1 months",strtotime('2019-08-31')))

 

后一年的日期為:

date("Y-m-d",strtotime("+1 years",strtotime('2019-08-31')))

 

如果不是1,就把+1或者-1換成+n或者-n就可以了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM