PHP Checking if the current date is before or after a set date

前端 未结 10 796
无人共我
无人共我 2021-02-01 13:10

Im pulling a date from a database which is formatted like dd-mm-YYYY.

What I want to do is check the current date;

  • if the current date is before the date com
10条回答
  •  爱一瞬间的悲伤
    2021-02-01 13:49

    if(strtotime($row['database_date']) > strtotime('now')) echo $row['database_date'];
    else echo date("d-m-Y");
    

    No need to check the hours because if they are on the same day it will show the same date either way...

提交回复
热议问题