Put an input date


Friends, I have a normal input

<input type="datetime-local" class="form-control" id="fecha_y_hora_de_creacion">

and with ajax I bring the value of this input that is in a db and the server is like this:

2018-05-24 17:58:44

How do I load the value into the input if I can not do it this way?


the variable res [0] .date_and_hours_of_creation is the one that contains the value that comes from the DB and is 2018-05-24 17:58:44

Thanks for the little man.

asked by Mauricio Delgado 30.05.2018 в 00:42

1 answer


To set the correct value, you must separate date and time with a T like this:

$('#fecha_y_hora_de_creacion').val(res[0].fecha_y_hora_de_creacion.replace(' ', 'T'));
answered by 30.05.2018 в 00:48