func(){ var date1="2021-05-06 00:00:00"; var date2="2021-05-08 00:00:00"; var start = new Date(date1); var end = new Date(date2); console.log(start); console.log(end); }