Linked Questions

Popular Questions

Locales - why does dayjs behave like this?

Asked by At

I need all dates to be assumed as locale en-gb (ie DD/MM/YYYY)

import dayjs from 'dayjs'
import 'dayjs/locale/en-gb'
dayjs.locale('en-gb')

const date = '01/02/2000' // 1st Feb
console.log(dayjs(date).format('DD/MM/YYYY')) // 02/01/2000 (wrong!)

Why is it assuming that the date is in usa format, when I have already set the locale?

Related Questions