I have a implemented a datepicker, on the selected date, should +2 to the date. and return the both dates that is before adding +2 and after adding +2.
for eg
from the datepicker, will get date like thisWed Jan 08 2020 15:53:01 GMT+0800 (Philippine Standard Time)
I would like to know how to do in Javascript, if the date is Jan 31 2020 15:53:01 GMT+0800
, the should be
31-01-2020,
01-02-2020
also if the date is 31 Dec 2019
should be 31-12-2019, 01-01-2020
Expected Output:
08-01-2020,
09-01-2020
var result = function getAllDates("Wed Jan 08 2020 15:53:01 GMT+0800 (Philippine Standard Time)");
functions getAllDates(datestr){
var formatDate = dateStr.toLocaleDateString("en-GB").replace(/\//g,"-");
var splitdate = dateStr.getDate() + 2;
var splitmonth = dateStr.getMonth();
var splityear = dateStr.getYear();
return splitdate+"-"+splitmonth+"-"+splityear
}