Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate laravel date firmat with Y-m-dTH:i:s

I'm building an API and it should accept date and time value as the format of Y-m-dTH:i:s. The specialty of this that there's T in the middle between date and time.

So, how to write validation rule to check this ?

'start_at' => 'required|date_format:Y-m-d H:i:s'

This is what I currently have.

like image 777
Tharindu Thisarasinghe Avatar asked Feb 22 '18 07:02

Tharindu Thisarasinghe


1 Answers

Try to use \T like this:

'start_at' => 'required|date_format:Y-m-d\TH:i:s'
like image 97
Alexey Mezenin Avatar answered Oct 03 '22 20:10

Alexey Mezenin