How do I make the validation rule before:end_date
+1 day? IE I want to make the rule before or including the end date. I know that the date is passed to the php strtotime function which takes '+1 days' as an argument but I can't get it to work.
protected $fillable = array('name','start_date', 'end_date', 'registration_start', 'registration_end');
public static $rules = array(
'registration_end' => 'required|date|before:end_date + 1 days'
);
You don't need to worry about you can edit the end_date
. You should do this to add a day before you pass to your rule.
$end_date = '<your date> +1 day';
Note : Replace <your date>
with your original date ('Ymd' or 'Y/m/d' format works)
Then you shall pass it to the rule as usual
public static $rules = array(
'registration_end' => 'required|date|before:'.$end_date
);
Just use request key :
'registration_end' => 'required|date|before:end_date'
if you want end_date
to precede registration_end
.
For specific time add time text before:end_date +1 day
.
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.