Finding the number of days between two dates

后端 未结 30 2461
心在旅途
心在旅途 2020-11-21 23:47

How to find number of days between two dates using PHP?

30条回答
  •  终归单人心
    2020-11-22 00:13

    If you are using MySql

    function daysSince($date, $date2){
    $q = "SELECT DATEDIFF('$date','$date2') AS days;";
    $result = execQ($q);
    $row = mysql_fetch_array($result,MYSQL_BOTH);
    return ($row[0]);
    

    }

    function execQ($q){
    $result = mysql_query( $q);
    if(!$result){echo ('Database error execQ' . mysql_error());echo $q;}    
    return $result;
    

    }

提交回复
热议问题