Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

johnnw's avatar

"The date does not match the format d/m/Y H:i:s."

I'm trying to store a date value but is always appearing the validation error:

"The date does not match the format d/m/Y H:i:s."

Do you know where can be the issue? Validate method:

$this->validate($request, [
      'date1' => 'required|date_format:d/m/Y H:i:s',
      'date2' => 'required|date_format:d/m/Y H:i:s|after_or_equal:date1',
 ]);

To create Im using carbon to format the dates:

 Carbon::createFromFormat('d/m/Y H:i:s', $request->date1)
Carbon::createFromFormat('d/m/Y H:i:s', $request->date2)

The Js code is:

$( ".input-group.date").datetimepicker({
        format: "dd MM yyyy - hh:ii",
        autoclose: true,
        todayBtn: true,
        minuteStep: 5
    });
0 likes
1 reply
Cronix's avatar
Cronix
Best Answer
Level 67

Your javascript date format is not d/m/Y H:i:s, it's dd MM yyyy - hh:ii so obviously that won't match in validation.

But, why use that format in the first place when sending from javascript? How are you storing it in the database (field type)? Why not just use yyyy-mm-dd h:i:s and then you don't need to convert it.

2 likes

Please or to participate in this conversation.