i want to compare two dates and am using
new Date('december 2019')
and it is not working in react js / react native
var resultList = [];
var dated = new Date('december 2019');
var endDated = new Date('march 2020');
var monthNameList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
while (dated <= endDated)
{
console.log('checking');
var stringDate = monthNameList[dated.getMonth()] + " " + dated.getFullYear() + " Qist is " + this.state.qistprice;
resultList.push(stringDate);
dated.setMonth(dated.getMonth()+1);
}
in vanilla javascript it is working fine . but in react native it is not working if i try using format like that
new Date('december 13, 2019') then it will work but i dont want that i just want 'december 2019' to work .. is there any way around ?
code that i have tried in vanilla js is this
var resultList = [];
var dated = new Date('december 2019');
var endDated = new Date('march 2020');
var monthNameList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
while (dated <= endDated)
{
console.log('checking');
var stringDate = monthNameList[dated.getMonth()] + " " + dated.getFullYear() ;
resultList.push(stringDate);
dated.setMonth(dated.getMonth()+1);
}
console.log(resultList)