I am using this piece of code to get string representing date yyyy-mm-dd
from a hidden field and then format it as needed:
var date_string = $('#end-date').val();
var splitDate = date_string.split("-");
var end_date = new Date(splitDate[0], splitDate[1] - 1, splitDate[2]);
end_date.format("dddd, mmmm dS, yyyy")
But it throws an error:
end_date.format is not a function
Why does it happen and how to solve this issue?