我有一个列名(available _on(,它在字符串中有一个值(‘11/10/2020-11/14/2020’(,现在我想应用当前日期存在于该字符串之间的条件,即在11/10/2020和11/14/2020 之间
我想在mysql查询中做到这一点。
您也可以在laravel或php中给出解决方案
// if available_on is from a object named $data so :
$availableOn = explode(" - ", $data->available_on); // split two date
$dateFrom = strtotime($availableOn[0]); // convert into unix_timestamp
$dateTo = strtotime($availableOn[1]);
if( time() > $dateFrom AND time() < $dateTo ){ // check if current time() between two
return true; // it's in available time
}else{
return false; // it's not in this time
}