set date on time moment code example
Example 1: javascript get time ago with moment
const dateTimeAgo = moment("2020-04-04 11:45:26.123").fromNow();
console.log(dateTimeAgo); //> 6 minutes ago
Example 2: moment set time
const date = "2017-03-13";
const time = "18:00";
const timeAndDate = moment(date + ' ' + time);
console.log(timeAndDate);