latz
5 months ago
66
5
Lumen

Problem with german date format

Posted 5 months ago by latz

Hello,

i have problems with german date format and postgresql.

this is part of json request to the API: trainingsdate: "21.02.2019"

Validation in the controller:


        $this->validate($request, [
            'art' => 'required|max:1|min:1',
            'trainingsdate' => 'required|unique:trainings|date|date_format:d.m.Y'
        ]);

and save the data to the database:

$training = new Training([
            'trainingsdate' => $request->get('trainingsdate'),
            'art' => $request->get('art'),
          ]);
        $training->save();

I've got an error:

SQLSTATE[22008]: Datetime field overflow: 7 ERROR: date/time field value out of range: "21.02.2019"

My timezone is set it to Europe/Zurich How can i use the german date format (dd.mm.yyyy) in lumen?

Please sign in or create an account to participate in this conversation.