php - How to take time as an input in Laravel? -
i want take input time am/pm using laravel controller mysql. problem have taken time blade view while seeing output using dd() it's showing following value.
carbon {#213 ▼ +"date": "2016-05-09 00:00:00.000000" +"timezone_type": 3 +"timezone": "utc" }
means nothing save start value.
here model:
class room extends model { protected $table='allocate_rooms'; }
here view i've used:
<div class="form-group"> <label>from</label> <input type="time" name="start" class="form-control" required > </div>
here controller i'm using.
public function allocateroom(request $request) { $room = new room(); $room->start =carbon::parse($request->input('start')); dd($room->start); $room->save(); }
in database have used time
datatype start
in model need date mutator:
class room extends model { protected $table='allocate_rooms'; protected $dates = ['start']; }
more information:
https://laravel.com/docs/5.1/eloquent-mutators#date-mutators
Comments
Post a Comment