skip to Main Content

Why does toISOString() function convert Javascript’s Sat Apr 01 2023 00:00:00 GMT+0530 (India Standard Time) to the previous day?

const currentDate = new Date(); const lastMonthStartDate = new Date( currentDate.getFullYear(), currentDate.getMonth() - 1, 1 ); const lastMonthEndDate = new Date( currentDate.getFullYear(), currentDate.getMonth(), 0 ); from = lastMonthStartDate.toISOString().split("T")[0]; to = lastMonthEndDate.toISOString().split("T")[0]; console.log(lastMonthStartDate, lastMonthEndDate); console.log(from,"last month" ,to); while executing this I…

VIEW QUESTION
Back To Top
Search