I want to ask, how can we validate dates from Excel file. I have encountered some weird test cases below.
Firstly, I have inputted 5/13/2021 in my excel file, but when I dump in, it doesn't display same, instead it displays 44329.
But fortunately I could able to display to 5/13/2021 using the following codes:
$temp = Carbon::instance(\PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($value));
$datetime = Carbon::parse($temp);
So, my big problem here is I can't use before
or after
validations. Like below codes it always fail even though, I fill it in correctly.
return Validator::make($rows->toArray(), [
'*.0' => 'required|after:now|before:0.1' //publish_at
'*.1' => 'required|before:0.0' // expired_at
])->validate();
As you can see in the picture below, the value of publish_at
is 44329, and expired_at
is 44330. I don't know why it fails. I tried also gt
or lt
validation it still fails.
Someone knows how to do it. would appreciate it.