find if date is older than 30 days

前端 未结 5 1625
我寻月下人不归
我寻月下人不归 2020-12-23 09:01

The date string looks like this

2011-08-19 17:14:40

(year-month-day hours:minutes:seconds)

How can I find out if the date is older than

5条回答
  •  孤城傲影
    2020-12-23 09:37

    You can use Carbon as follows

    if (30 - ((new \Carbon\Carbon($given_date, 'UTC'))->diffInDays()) < 0) {
        echo "The date is older than 30 days";
    }
    

提交回复
热议问题