Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knubbe82's avatar

Validate date after and before

I have a time field id database and in model I use protected $dates = ['time'];. Before saving a new record I must be sure that new record time is after last record time if that record exist (maybe it's first entry). How can I do that? I try this but it's not working

'time'              => 'required|after:'.$latestTime,
0 likes
2 replies
Mahaveer's avatar

@knubbe82 Try this.

'time' => 'required|after_or_equal:'.(date('H:i:s')),

Hope it helps!.

knubbe82's avatar

How this (date('H:i:s')) refers to last recorded time attribute?

Please or to participate in this conversation.