Date minus 1 year?

前端 未结 8 1922
时光取名叫无心
时光取名叫无心 2020-11-27 14:28

I\'ve got a date in this format:

2009-01-01

How do I return the same date but 1 year earlier?

8条回答
  •  自闭症患者
    2020-11-27 15:14

    On my website, to check if registering people is 18 years old, I simply used the following :

    $legalAge = date('Y-m-d', strtotime('-18 year'));
    

    After, only compare the the two dates.

    Hope it could help someone.

提交回复
热议问题