1

I have birthday field in my form.and type is date string (picked by date picker). I validate this request by

'birthday'=>'required|date_format:"d/m/Y"|after:"01-01-1396"',

But in Solar Hijri calendar we have date like 31/06/1396 and the validator say not match d/m/Y and it's say truth.

Now how can I check Solar Hijri (SH) date ?

In Solar Hijri (SH) calendar The first six months have 31 days, the next five have 30 days, and the last month has 29 days in usual years but 30 days in leap years.

amin saffar
  • 1,953
  • 3
  • 22
  • 34

1 Answers1

1

I use this regex now But it's not check leap years and all 12 month can be 30

THIS for Y/m/d

'birthday'=>['required' ,'regex:/^\d{4}[\/\-]((0?[1-6])[\/\-](0?[1-9]|[12][0-9]|3[01])|(0?[7-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|30))$/']
amin saffar
  • 1,953
  • 3
  • 22
  • 34
  • you can use this `'date'=>'required|regex:/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/' ` – Ajay Kumar Sep 20 '17 at 21:00
  • 1
    why you get Dates in Jalali or Hijri format from client? this is strange for me. we always get Gregorian and convent all Date to Gregorian. – saber tabatabaee yazdi Aug 12 '20 at 07:18
  • 1
    @sabertabatabaeeyazdi On that project we define in api to handle date in server site but absolutely we can convert input date in client to Gregorian and then send to server. – amin saffar Aug 12 '20 at 17:42