how to check if it is valid moment object else convert js code example
Example 1: moment check valid date
var date = moment("2016-10-19");
var check = date.isValid();
console.log(check);
Example 2: javascript get time ago with moment
const dateTimeAgo = moment("2020-04-04 11:45:26.123").fromNow();
console.log(dateTimeAgo); //> 6 minutes ago