code: 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();
      }
docs: Use moment to format the date
  @param date
  @param lang
  @param type
  @returns {*}