To use moment.js to convert date to string in mm/dd/yyyy format with JavaScript, we use the format
method.
For instance, we write
const startDate = moment().format("MM/DD/YYYY HH:mm:ss");
to create a moment object with moment
with the current datetime.
Then we call format
with a format string to return a string in mm/dd/yyyy format with the time in hours:minutes:seconds format.