Open GabrielOkane opened 3 years ago
Make a dayjs.js
file in plugins
folder and write code below.
export default function ({ $dayjs }) {
$dayjs.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years',
},
})
}
And add this plugin to nuxt.config.js
.
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [ '~/plugins/dayjs'],
Finally, add updateLocale to dayjs config in nuxt.config.js
...
dayjs: {
locales: ['en'],
defaultLocale: 'en',
defaultTimeZone: 'America/New_York',
plugins: ['timezone', 'relativeTime', 'updateLocale'],
},
...
@k4sud0n How to use in nuxt3?
I would like to change the format for relativeTime: https://day.js.org/docs/en/customization/relative-time. But i dont know how implement in nuxtconfig