How can I compare two dates in PHP?

前端 未结 13 2254
一整个雨季
一整个雨季 2020-11-22 06:02

How can I compare two dates in PHP?

The date is stored in the database in the following format

2011-10-2

If I wanted to

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 06:43

    Found the answer on a blog and it's as simple as:

    strtotime(date("Y"."-01-01")) -strtotime($newdate))/86400
    

    And you'll get the days between the 2 dates.

提交回复
热议问题