vendredi 18 décembre 2020

can't validate true or false var_dump in laravel carbon

I write code to check current time between 2 times $start and $end like this:

$current = new Carbon();
$start = product::select('dateS')->where('id',$req->id)->first(); 
$end = product::select('dateE')->where('id',$req->id)->first();
$val= var_dump($current->between($start->dateS,  $end->dateE));

It work and when i use dd($val) it will show:

bool(false) null or bool(true) null

Next, i want to do like this but it only returns else case. What did I do wrong?

 if($val == true){
      echo "current time is between start and end";
    }
    else{
      echo "current time isn't between start and end";
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire