PHP date comparison

后端 未结 9 541
长情又很酷
长情又很酷 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:21

    There should be you variable date Like

    $date_value = "2013-09-12";
    $Current_date = date("Y-m-d"); OR $current_date_time_stamp = time();
    

    You can Compare both date after convert date into time-stamp so :

    if(strtotime($current_date) >= strtotime($date_value)) {
     echo "current date is bigger then my date value";
    }
    

    OR

    if($current_date_time_stamp >= strtotime($date_value)) {
     echo "current date is bigger then my date value";
    }
    

提交回复
热议问题