convert date picker to persian mode

This commit is contained in:
2023-07-10 16:24:50 +03:30
parent f93040c32f
commit 362bf43bee
3 changed files with 15 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { LocalizationProvider, DatePicker } from "@mui/x-date-pickers";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali";
import moment from "moment/moment";
import { useTranslations } from "next-intl";
@@ -12,15 +12,14 @@ export default function MuiDatePicker({
const t = useTranslations();
const handleDateChange = (date) => {
const selectedDate = moment(date).locale("en").format("YYYY-MM-DD");
const selectedDate = moment(date).locale("fa"); // should add .format() at the end to format the data
setFieldValue(selectType, selectedDate);
};
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<LocalizationProvider dateAdapter={AdapterDateFnsJalali}>
<DatePicker
sx={{ width: "100%" }}
format="YYYY-MM-DD"
label={t("MuiDatePicker.date_picker_birthday")}
slotProps={{
textField: {