Function to generate date string on the format YYYY-MM-DD

/**
* To generate Date String on the format YYYY-MM-DD
* @param {Date} dateObj - javascript Date Object
*/
function generateDateString(dateObj) 
{
     return (
                dateObj.getFullYear() +
                "-" +
                (dateObj.getMonth() + 1) +
                "-" +
                dateObj.getDate()
      );
}

Leave a comment

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