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

Yorkata's avatar

Show already selected date

If the type="date" is already selected I want it to be displayed on my edit page. Currently, only the format is shown mm/dd/yyyy.

Tried something like this but it did not work:

value="{{ ($competition->start_date) ? $competition->start_date->format('Y/m/d'):'' }}"
0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

To display the already selected date in the input field, you can set the value attribute of the input field to the formatted date string. Here's an example:

<input type="date" name="start_date" value="{{ $competition->start_date ? $competition->start_date->format('Y-m-d') : '' }}">

Note that the value attribute should be set to the date string in the format "YYYY-MM-DD" for the input field to display the selected date.

1 like

Please or to participate in this conversation.