最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - start antd RangePicker (datepicker) week from monday instead of sunday - Stack Overflow

programmeradmin4浏览0评论

i am using antd RangePicker to get start and end value of date. my calanders starts from sunday but i want to start it from monday

enter image description here

i have try this solution but nothing works

import { LocaleProvider, Calendar } from 'antd';
import en_GB from 'antd/lib/locale-provider/en_GB';
<LocaleProvider locale={en_GB}>
<Calendar
    dateFullCellRender={dateFullCellRender}
    onSelect={this.onSelect}
    defaultValue={this.state.selectedDate}
    ...
/></LocaleProvider>

i am using antd RangePicker to get start and end value of date. my calanders starts from sunday but i want to start it from monday

enter image description here

i have try this solution but nothing works

import { LocaleProvider, Calendar } from 'antd';
import en_GB from 'antd/lib/locale-provider/en_GB';
<LocaleProvider locale={en_GB}>
<Calendar
    dateFullCellRender={dateFullCellRender}
    onSelect={this.onSelect}
    defaultValue={this.state.selectedDate}
    ...
/></LocaleProvider>
Share Improve this question asked Dec 16, 2021 at 7:31 TariQ Mahmood AliTariQ Mahmood Ali 431 silver badge6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

The antd doc doesn't work for me.

This works for me:

import dayjs from 'dayjs';
import updateLocale from 'dayjs/plugin/updateLocale';

dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
    weekStart: 1
})

From antd documentation here

import 'moment/locale/en-gb';
import locale from 'antd/es/locale/en_GB';
import moment from 'moment';

moment.locale('en-gb', {
  week: {
    dow: 1 /// Date offset
  }
});

EDIT: Seems that after a few years, the way of doing this has changed (Again according to the linked documentation), now it should be done this way:

import dayjs from 'dayjs';
import 'dayjs/locale/en_GB';
import 'dayjs/plugin/updateLocale';

dayjs.updateLocale('en_gb', {
  weekStart: 0,
});
发布评论

评论列表(0)

  1. 暂无评论