Parse your selected
variable:
var
selected = '2016-03-26';
selectedToArray = selected.split('-'),
year = selectedToArray[0], // 2016
month = selectedToArray[1], // 03
day = selectedToArray[2]; // 26
The split()
method splits a String object into an array of strings by separating the string into substrings. You can read more about this function here.
Update:
$('.from_date').datepicker(
{
dateFormat: "yy-mm-dd",
onSelect: function() {
var
selected = $(this).val(),
selectedToArray = selected.split('-'),
year = selectedToArray[0],
month = selectedToArray[1],
day = selectedToArray[2];
$('#some_div_for_year').text(year);
$('#some_div_for_month').text(month);
}
}
);