How to format the date

 /**
        * Defines the function to convert the date time into mm/dd/yyyy format.
        * @param {Date} dateValue
        * @returns {Date} dateFormat
        */
        function formatDate(dateValue) {
            try {
                let dateDay = dateValue.getDate();
                let dateMonth = dateValue.getMonth() + 1;
                let dateYear = dateValue.getFullYear();
                let dateFormat = dateMonth + "/" + dateDay + "/" + dateYear;
                return dateFormat;
            }
            catch (e) {
                log.error("error@formatDate", e.message);
                return null;
            }
        }

Leave a comment

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