Change locale in react-datepicker

后端 未结 6 1162
一向
一向 2021-02-04 03:30

I am using react-datepicker NPM package,
I tried to follow documentation but I was unable to import

registerLocale 

and

         


        
6条回答
  •  广开言路
    2021-02-04 03:48

    For those who don't want to depend on date-fns module you can define your own localization.

    const months = ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık']
    const days = ['Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct', 'Pz']
    
    const locale = {
      localize: {
        month: n => months[n],
        day: n => days[n]
      },
      formatLong: {}
    }
    
    
    

提交回复
热议问题