utils/date.formater.js
function getFormattedDate(date, lang, type) {
        date = date || new Date();
        lang = lang || 'en';
        type = type || 'long';

        // set the language for en
        if (lang === 'en' && type === 'short') { lang = 'enshort'; }
        if (lang === 'en' && type === 'medium') { lang = 'enmedium'; }

        // get the date string
        return moment(date).locale(lang).fromNow();
    }
function getFormattedDate(date, lang, type) {
        date = date || new Date();
        lang = lang || 'en';
        type = type || 'long';

        // set the language for en
        if (lang === 'en' && type === 'short') { lang = 'enshort'; }
        if (lang === 'en' && type === 'medium') { lang = 'enmedium'; }

        // get the date string
        return moment(date).locale(lang).fromNow();
    }
function getFormattedDate ( date , lang , type ) { date = date || new Date ( ) ; lang = lang || 'en' ; type = type || 'long' ; // set the language for en if ( lang === 'en' && type === 'short' ) { lang = 'enshort' ; } if ( lang === 'en' && type === 'medium' ) { lang = 'enmedium' ; } // get the date string return moment ( date ) . locale ( lang ) . fromNow ( ) ; }
Use moment to format the date
@param date
@param lang
@param type
@returns {*}
Use moment to format the date