PHP date comparison

后端 未结 9 735
长情又很酷
长情又很酷 2021-02-02 16:10

How would I check if a date in the format \"2008-02-16 12:59:57\" is less than 24 hours ago?

9条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 16:26

    Php has a comparison function between two date/time objects, but I don't really like it very much. It can be imprecise.

    What I do is use strtotime() to make a unix timestamp out of the date object, then compare it with the output of time().

提交回复
热议问题