I want to check if date and time where stored in the session are not in the past and greater than 15 minutes of the current time
$time = Session::get('preorder_time');
$date = Session::get('preorder_date');
ex.
$date = "2020-08-15";
$time = "21:30";
I want to check if this time and date plus 15 minutes greater than current time
use carbon:
if(\Carbon\Carbon::parse($date.' '.$time)->addMinutes(15)->gt(\Carbon\Carbon::now())
{
//your code
}
Pretty much all builtin date functions can parse that format, so:
$date = "2020-08-15";
$time = "21:30";
if (strtotime("$date $time") + 15*60 < time()) {
} else {
}
To inspect the value:
var_dump(date('r', strtotime("$date $time")));
string(31) "Sat, 15 Aug 2020 21:30:00 +0200"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.