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

partabsaifzakir's avatar

HOW TO STORE AND FETCH DATE IN LARAVEL USING CALENDAR

i need a field in a form in which a user open calendar, select desire date and when he submit the form... date store in database, can any one tell me how to do it from scratch.

  • In migration what type should i select for the column in which i need to store date in DB.
0 likes
5 replies
Sergiu17's avatar
Sergiu17
Best Answer
Level 60
<form action="{{ route('your-route') }}" method="post">
    @csrf
    <input type="date" name="date">
    <input type="submit" value="Submit">
</form>
public function store(Request $request) {
    dd($request->all());
}
// output
array:2 [▼
  "_token" => "rVswqfdm4sw6dwarRaJj0Kfnmm4UGagc3sadRiP8xS6qZ"
  "date" => "2018-09-27"
]
public function store(Request $request) {
    $model = new Model();
    $model->date = $request->date;
    $model->save();
}

Done! In this case Model is a placeholder, just use your own model, or DB to insert data.

1 like

Please or to participate in this conversation.