Formats an input date string into “DD/MM/YYYY” format using moment.js

  /**

         * Formats an ISO date string into “DD/MM/YYYY” format.

         *

         * @param {string} isoDateStr – The ISO date string to be formatted.

         * @returns {string} – The formatted date string in “DD/MM/YYYY” format.

         * @throws {Error} – Logs an error if the formatting fails.

         */

        function formatDateForRequest(isoDateStr, ) {

            try {

                let dateData = new Date(isoDateStr);

                let formattedDate = moment(dateData).format(‘DD/MM/YYYY’);

              return formattedDate

            } catch (e) {

                log.error(‘error @ formatDateForRequest’, e);

                return ;

            }

        }

Leave a comment

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