Moment.js “Invalid date”

Suppose your date is in format ‘DD-MM-YYYY’ & you want to display it in DD-MMM format then you can do this by first telling moment function which format your date currently is & then asking it to convert it to required format. Below is the example:

var taskDueDate = moment(dueDate, 'DD-MM-YYYY').format('DD-MMM');

This way you can convert your date in any format.

Leave a Comment