I have a string like this - 2019-10-21 14:54:00
And five dropdown elements (for years, months, days, hours and minutes) like this:
<select id='selMonth'>
<option>01</option>
<option>02</option>
...
</select>
Now I need to place values from the string inside the corresponding elements, like this:
$('#selMonth').val(month-from-string);
$('#selHour').val(hour-from-string);
I tried to split the string, firstly by space
, then first part by -
and the second part by :
but I hope there is a more natural way.
Any help?