Skip to content

Commit

Permalink
Use date library API over library internals
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Dec 23, 2024
1 parent a5b8706 commit ac50b04
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docs/data/data-grid/custom-columns/EditingWithDatePickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { enUS as locale } from 'date-fns/locale';

const dateAdapter = new AdapterDateFns({ locale });
import format from 'date-fns/format';

/**
* `date` column
Expand All @@ -41,7 +40,7 @@ const dateColumnType: GridColTypeDef<Date, string> = {
})),
valueFormatter: (value) => {
if (value) {
return dateAdapter.format(value, 'keyboardDate');
return format(value, 'MM/dd/yyyy', { locale });
}
return '';
},
Expand Down Expand Up @@ -123,7 +122,7 @@ const dateTimeColumnType: GridColTypeDef<Date, string> = {
})),
valueFormatter: (value) => {
if (value) {
return dateAdapter.format(value, 'keyboardDateTime');
return format(value, 'MM/dd/yyyy hh:mm a', { locale });
}
return '';
},
Expand Down

0 comments on commit ac50b04

Please sign in to comment.