Custom year / date formatting with vue-i18n

Viewed 736

I'm currently using Vue I18n for date-time formatting for multiple locales.

When using the short format, the year is 'numeric' which shows every number in the year. For example 2020 would show as "2020", A year of 190 would show "190".

Vue i18n uses the EMCAScript Internationalization Spec and date formats can be found here and only documents 'numeric' and '2-digit' for year.

My question is asking if its possible to create a new '4-digit' format so taking the example above 190 would show "0190"?

date = this.date && this.$d(moment(this.date), 'short');

export const DATE_TIME_FORMATS = {
  'en-US': {
    short: {
      day: '2-digit',
      month: '2-digit',
      year: 'numeric'
    },
    long: {
      day: '2-digit',
      month: '2-digit',
      year: 'numeric',
      hour: 'numeric',
      minute: '2-digit',
      hour12: true
    }
  },
  ...

0 Answers
Related