return [
'deadline' => 'required|date_format:Y-m-d H:i:s|after_or_equal:today',
];
$request->validate([
'start_date' => 'date_format:d/m/Y',
'end_date' => 'date_format:d/m/Y'
]);
'dob' => 'required|date_format:Y-m-d|after_or_equal:1920-01-01'
return [
'deadline' => 'date_format:Y-m-d H:i:s'
];
'start_date' => 'required|date|after:tomorrow'
'day' => 'required|date',
public function validateDate($attribute, $value)
{
if ($value instanceof DateTimeInterface) {
return true;
}
if ((! is_string($value) && ! is_numeric($value)) || strtotime($value) === false) {
return false;
}
$date = date_parse($value);
return checkdate($date['month'], $date['day'], $date['year']);
}
############## OR ###################
public function validateDateFormat($attribute, $value, $parameters)
{
if (! is_string($value) && ! is_numeric($value)) {
return false;
}
$format = $parameters[0];
$date = DateTime::createFromFormat('!'.$format, $value);
return $date && $date->format($format) == $value;
}