Hello I have the following line of code in my application:
$deposit = new BankDeposit();
$deposit->date_occurred = Carbon::createFromFormat('d/m/Y', $request->date_occurred);
$deposit->amount = $request->amount;
$deposit->save();
where $request->date_occurred
is 19/10/2016.
Now something funny is happening, when I post this data from my android app and to the server, the server receives the date but somehow parses and saves it as
0016-10-19 08:48:14
However when I post from postman using exactly the same values I did in the android app I get:
2016-10-19 08:48:14
I've inspected both requests and I can't tell what is wrong. This is the request and response when I use postman:
{
"request": {
"date_occurred": "19/10/2016",
"amount": "5000"
},
"response": {
"date_occurred": "2016-10-19 08:52:33",
"amount": "5000",
"updated_at": "2016-10-06 08:52:33",
"created_at": "2016-10-06 08:52:33",
}
}
This is what I see when I log the response in my android monitor:
{
"request": {
"date_occurred": "19\/10\/16",
"amount":"2323"
},
"response": {
"date_occurred": "0016-10-19 08:48:14",
"amount": "2323",
"created_at": "2016-10-06 08:48:14",
"updated_at": "2016-10-06 08:48:14"
}
}
Your android app is not sending the "Y" year notation. But it's sending in y.