You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I pass locales dynamically to DateRangePicker to get those formats where as I'm using moment/min/locales for locale changing. when I import 'moment' and trying to change moment.locale() it is not working. So is there any way to change the locale in DateRangePicker.
Here is my code <DateRangePicker startDate={this.props.startDate} endDate={this.props.endDate} maxDate={moment()} ranges={config(this.props.l)} onEvent={this.handleEvent} opens="left" locale={{ format: dateFormatBasedOnCountry[this.props.langCode.toUpperCase()], cancelLabel: this.props.l('Cancel'), applyLabel: this.props.l('Apply'), customRangeLabel: this.props.l('Custom Range'), }} key={this.state.isTransChanged ? date-range-picker-${this.state.index++} : undefined} // added key to remount // the component for translations >
The text was updated successfully, but these errors were encountered:
If you need to set local dynemic in react-bootstrap-daterangepicker you can set it in initialSettings.locale like this
const [lang, setLang] = useState(getCookie(authConstants.language) || "en");
initialSettings={{
startDate: period[0], endDate: period[1],
locale: {
locale: moment.locale(lang), // lang
cancelLabel: t("cancel"),
applyLabel: t("apply"),
format: "DD.MM.YYYY"
},
}}
How can I pass locales dynamically to DateRangePicker to get those formats where as I'm using
moment/min/locales
for locale changing. when I import 'moment' and trying to change moment.locale() it is not working. So is there any way to change the locale in DateRangePicker.Here is my code
<DateRangePicker startDate={this.props.startDate} endDate={this.props.endDate} maxDate={moment()} ranges={config(this.props.l)} onEvent={this.handleEvent} opens="left" locale={{ format: dateFormatBasedOnCountry[this.props.langCode.toUpperCase()], cancelLabel: this.props.l('Cancel'), applyLabel: this.props.l('Apply'), customRangeLabel: this.props.l('Custom Range'), }} key={this.state.isTransChanged ?
date-range-picker-${this.state.index++}: undefined} // added key to remount // the component for translations >
The text was updated successfully, but these errors were encountered: