Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1678x 677x 1001x 1001x 1001x 22x 979x | import moment from 'moment';
import i18n from 'i18next';
/**
* Format date
*
* @param {string} date Date to be formatted
* @param {string} format Desired date format
* @returns {string} Formatted date
*/
export default (date, format = i18n.t('Common:localDateFormat', 'DD-MMM-YYYY')) => {
if (!date) {
return '';
}
const locale = i18n.language || 'en';
const parsed = moment(date, ['YYYYMMDD', 'YYYY.MM.DD'], true);
if (!parsed.isValid()) {
return moment(date).locale(locale).format(format);
}
return parsed.locale(locale).format(format);
};
|