I'm trying to validate date time through Laravel Validation like this:
$this->validate($request,[
'DateTime'=> 'required|after_or_equal:' . date('Y-m-d H:i:s'),
]);
I want to restrict the user if they enter date time greater than current date time but in my case date is being validated but i have to validate time also. Format of date time is 2020-12-23 17:40:00
Try this:
$this->validate($request,[
'DateTime'=> 'required|date_format:Y-m-d H:i:s|after_or_equal:' . date(DATE_ATOM),
]);
And if you want to change the time you can do sth like this:
'request_date'=>'after:'.date(DATE_ATOM, time() + (5 * 60 * 60)),
Or
'request_date' => 'required|date_format:Y-m-d H:i:s|after:5 hours'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With