I want to emit the day after the selected day.
$('#toDate').datepicker({
inline: true,
altField: '#x',
dateFormat: "dd-mm-yy", //day
altFormat: "yy-mm-dd", //year
monthNames: ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
dayNamesMin: ["Pa", "Pt", "Sl", "Ça", "Pe", "Cu", "Ct"],
firstDay: 1,
numberOfMonths: 1,
onSelect: function(dateText, inst) {
var dateup = ('0' + (parseInt(inst.selectedDay) + 1)).slice(-2);
var monthup = ('0' + (parseInt(inst.selectedMonth) + 1)).slice(-2);
var newdate = inst.selectedYear+'-'+monthup+'-'+dateup;
socket.emit('sockettoDate', newdate);
}
});
This code cannot calculate the day after the last day of month.
For example if 2017-12-31 selected, result is 2017-12-32. Any solution?
if your date format is same as you have given in example then you can use following function for add days into date. After getting new date you can use new added date
function addDays(date, days) {
var result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
USE
addDays(new Date('2017-12-31 '),1);
OUT Put
Mon Jan 01 2018 00:00:00 GMT+0530 (India Standard Time)