0

Some <td> tag contains a string date dd/mm/yyyy like 24/5/2012
I need to read this string date and use it to dynamically set the value of a dynamically created input date tag.

var stringDate = selectedEl.text();
anotherEl.html("<input type='date' value='" + stringDate + "'/>");

The code above has no effect. The Chrome browser just renders its empty default date picker field that contains: dd ----- yyy

Saleh Feek
  • 2,048
  • 8
  • 34
  • 56

1 Answers1

0

Input type date takes the format yyyy-mm-dd but displays the date localised to the browser (Chrome). So you should be able to supply the date in the format yyyy-mm-dd and it display correctly depending on localisation settings. Checkout this codepen

<input type="date" value="2008-09-05" />
Luke Baughan
  • 4,658
  • 3
  • 31
  • 54