How to get the names of next two months

function getMonthName() {
            try {
                const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
                let currentDate = new Date();
                currentDate.setMonth(currentDate.getMonth() + 1);
                const nextMonthName = monthNames[currentDate.getMonth()] + " " + currentDate.getFullYear();
                // Calculate the month after the next
                currentDate.setMonth(currentDate.getMonth() + 1);
                const nextTwoMonthsName = monthNames[currentDate.getMonth()] + " " + currentDate.getFullYear();
                return nextMonthName + " and " + nextTwoMonthsName
            } catch (err) {
                log.error("error@getMonthName", err)
            }
        }

Leave a comment

Your email address will not be published. Required fields are marked *