You are checking if the start_date bigger then both dateInStart and dateInStart
and the end_date smaller then both dateInStart and dateInEnd
are you sure this is what you want?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I tried to check if the date input is in between the start_date and end_date inside the database. but as it seems the value is not included when i try to check, it returns a false as output?
Example code :
$dateInStart = date("Y-m-d H:i:s",strtotime($data['start_date'])); //date input start $dateInEnd = date("Y-m-d H:i:s",strtotime($data['end_date']));//date input end
$checkDbStart = DB::table('campaigns')->where('start_date','>=', $dateInStart)->where('end_date','<=', $dateInStart)->where('start_date','>=', $dateInEnd)->where('end_date','<=', $dateInEnd)->exists();
example input : $dateInStart = "2020-02-06 00:00:00"; $dateInEnd = "2020-02-07 00:00:00";
//value in db //start_date = 06-02-2020 //end_date =09-02-2020
How to include the value of input cause if i try using the ifelse condition i am able to get the value as it included. But for date as I test it does not include the input value .
You are checking if the start_date bigger then both dateInStart and dateInStart
and the end_date smaller then both dateInStart and dateInEnd
are you sure this is what you want?
Please or to participate in this conversation.