How to convert date to a timestamp format and compare the timestamp with stored timestamps?
You can use a str_to_date directly in SQL code

 $stmt = mysqli_prepare($connect,"select amount,date 
                        from pl_per_day 
                        where date between str_to_date(?, '%Y-%m-%d %T) 
                            and str_to_date(?, '%Y-%m-%d %T)");
    mysqli_stmt_bind_param($stmt, "ss", $sdate, $edate);
    $result = mysqli_stmt_execute($stmt);

to avoid the risk of sql injection related to the use of php vars in sql using prepared statement and binding value.
Write
×