I want to get rid of the timestamp in this returned string. I am currently getting: "You have selected: Fri Sep 08 1978 00:00:00 GMT-0400 (EDT)"
The code is:
var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText);
$('.info').html('You have selected:' + '<br />' + chosenDates.toString());
You can specify the format in the toString
method. For example:
var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText);
$('.info').html('You have selected:' + '<br />' + chosenDates.toString('dd-MM-yyyy'));
Edit: Or if you want to use the same format as in the date-picker: yy-mm-dd
Edit: You can also try with the formatDate
function:
var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText);
var backToString = $.datepicker.formatDate('yy-mm-dd', chosenDates);
$('.info').html('You have selected:' + '<br />' + backToString);