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

PeterPan's avatar

How to display back date in Form:date (laravel collective)

In my form , I have this {{Form::date('date', \Carbon\Carbon::now())}}

In my controller, i did this:

$date = \Carbon\Carbon::parse($request->current_date);

$day = $date->day;
$month = $date->month;
$year = $date->year;

So during edit, I want to pass back the $date,$month,$year that I saved in database back to the blade template form. What is the format I need to pass back to the blade template ?

```{{Form::date('date', 'mm/dd/yyy'}}``???`

0 likes
4 replies
PeterPan's avatar

@tisuchi The laravel collective Form::date is able to provide something like a nice gui to pick the dates. During edit, I would like same feature when the user reclick the dates to picka new date.

PeterPan's avatar

I had to revert to plain HTML

     ```                 <input type="date" name="sale_date" value="{{$db->year}}-{{$db->month}}-{{$db->day}}" />```

And the format is "yyyy-mm-dd" even though the GUI is showing up as "mm-dd-yyy" at the text input.

PeterPan's avatar
PeterPan
OP
Best Answer
Level 1

The previous solution is buggy as some month & days might be single values in my database. e.g April is 4 in my DB but the display needs it as 04.

Here is the final solution:

<input type="date" name="sale_date" value="{{ \Carbon\Carbon::createFromDate($db->year,$db->month,$db->day)->format('Y-m-d')}}" />
1 like

Please or to participate in this conversation.