Here I'm trying in jQuery to print the number of the dates and Full weekday on particular day but it gives me the output shows like below:-
Output
[Fri Jun 01 2018 00:00:00 GMT+0530 (IST),
Sat Jun 02 2018 00:00:00 GMT+0530 (IST),
......,
......, //further till end date
]
The code I'm using is :-
var start = $("#txtFromDate").datepicker("getDate"),
end = $("#txtToDate").datepicker("getDate"),
currentDate = new Date(start.getTime()),
between = []
;
while (currentDate <= end) {
between.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
console.log(between);
Edited code:-
var start = $("#txtFromDate").val($.datepicker.formatDate('M dd yyyy', new Date())),
end = $("#txtToDate").val($.datepicker.formatDate('M dd yyyy', new Date())),
currentDate = new Date(start.getTime()),
between = []
;
while (currentDate <= end) {
between.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
console.log(between);
I tried this code too but not getting any useful output but it gives an error:-
Uncaught TypeError: start.getTime is not a function
at HTMLButtonElement. (setschedule:227)
at HTMLButtonElement.dispatch (jquery-1.12.4.js:5226)
at HTMLButtonElement.elemData.handle (jquery-1.12.4.js:4878)
Output I need is:-
[Friday, 06-01-2018,
Saturday, 06-02-2018,
......,
......, //further till end date
]
How can I will get my output Any help can be appreciate. Thank you.