Support the ongoing development of Laravel.io →
posted 5 years ago

Hi all. Im trying to validate the birthdate in my form: Code: pastebin link

My issue is, how do I validate the correct format? Im going for d-m-Y, but as i know, by default html forces input type=date as: Y-m-d instead, and I'm struggling to kinda convert it to reflect a real validation?

If i validate it as Y-m-d, everything is fine, but if i try to validate it as d-m-Y like 01-06-1991, it gives me this error: The birthday does not match the format d-m-Y.

How do I work around this?

I tried to validate like this without any luck: 'birthday' => ['required', 'string', 'max:100', 'date_format:d-m-Y'],

Last updated 3 years ago.
0

First of all the date shouldn't be a 'string' type. However if that works for you fine.

You could put this in your model.

         protected $dateFormat = 'Y-d-m';

Or whatever the format you're using.

0

Ive tried protected $dateFormat = 'd-m-Y H:i:s'; But it gave me a mysql error. Seems like mysql cant like that format then :S

Last updated 5 years ago.
0

Check this out I think this is exactly what you need.

  https://laracasts.com/discuss/channels/general-discussion/how-to-carbonparse-in-ddmmyyyy-format
0

Through our experts, we offer all kinds of Psychology Writing Services and Psychology Coursework Writing Help to suit the need of every student when they are given any Psychology Research Paper Writing Services. https://researchpapers247.com/psychology-writing-services/

0

When students seek our Psychology Writing Services from us, they are assured to receive Custom Psychology Writing Services that meets all their writing needs and Online Psychology Writing Services one that has been written following all the instructions. https://www.meldaresearch.com/psychology-writing-services/

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Morten kh4zy Joined 26 Jan 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.