Home > Mobile >  Setting default value for a datetime-local input field in Blade
Setting default value for a datetime-local input field in Blade

Time:03-22

I would like to set the value of an input:datetime-local field in Blade with data from the database but it only shows a blank placeholder values.

Below is my attempt which is not working:

<input type="datetime-local" value="{{ date('d/m/YH:i', strtotime($slider->run_to)) }}">

In my research, I have found out that the field needs value in this format YYYY-MM-DDTHH:MM or like in my case d/m/YTH:i where T is a string literal.

My problem is I am not able to find a way to do this in Laravel-Blade with dynamic data.

Is there any way to achieve it? If not then what alternatives are there for displaying date time in an input field?

CodePudding user response:

The format of enter image description here

enter image description here

Demo: enter image description here

Demo: https://3v4l.org/710EN

  • Related