parse is complaining that your data is not in the right format. Is it definitely a four digit year?
Jun 18, 2019
8
Level 1
Carbon createFromFormat not working
Hi, Im trying to get the last day of the week using Carbon. I am using the method createFromFormat. This is what I am doing (validatedData['date'] can be for example: 2019 04):
$first_date = Carbon::createFromFormat('Y W', $validatedData['date'])->startOfWeek();
I get the following error:
message: "The format separator does not match ↵Trailing data"
Level 104
Something in this format will work:
(new Carbon)->setISODate(2019, 17)->startOfWeek();
In this case, you would need to separate $validatedData['date'] into two variables:
[$year, $week] = explode(' ', $validatedData['date']);
$first_date = (new Carbon)->setISODate($year, $week)->startOfWeek();
1 like
Please or to participate in this conversation.