React-datepicker: Week always starts on Monday

Created on 27 Jul 2017  路  6Comments  路  Source: Hacker0x01/react-datepicker

Hi,

changing the locale seems to have no effect, the week always starts on Monday.

Thanks for this great library!

Most helpful comment

I solved it this way..

```
import enGb from 'date-fns/locale/en-GB';
import DatePicker, { registerLocale } from 'react-datepicker';
registerLocale('en-gb', enGb);

    const MyComponent = props => (
            <DatePicker
                 locale="en-gb"
            />
    );

All 6 comments

Hi,

i have the same issue, if someone have the answer.
That's be pretty cool !

I found a solution.

You have to insert : import 'moment/locale/en-gb';
and you can use locale="en-gb".

Now my week begin on Monday.

More generally, you can use any of moment's localization features: https://github.com/Hacker0x01/react-datepicker#localization

I solved it this way..

```
import enGb from 'date-fns/locale/en-GB';
import DatePicker, { registerLocale } from 'react-datepicker';
registerLocale('en-gb', enGb);

    const MyComponent = props => (
            <DatePicker
                 locale="en-gb"
            />
    );

How can I use react-datepicker with moment since it has more locales than date-fns ?

Also if your locale doesn't have the start date you wish, you can override the default values by doing this:

import DatePicker, { registerLocale } from "react-datepicker";
import es from "date-fns/locale/es";
registerLocale("es", { ...es, options: { ...es.options, weekStartsOn: 0 } });

const MyComponent = props => (
        <DatePicker
             locale="es"
        />
);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jcabrerazuniga picture jcabrerazuniga  路  3Comments

jbccollins picture jbccollins  路  3Comments

sarav1234 picture sarav1234  路  3Comments

ro-savage picture ro-savage  路  3Comments

pinturic picture pinturic  路  3Comments