我看不到在 React 应用程序中格式化 Material UI 日期选择器??
当用户选择一个日期时,我希望它的格式为 MM/DD/YYYY。我查了几个答案,但不清楚更改格式的功能应该去哪里???由于某种原因,它没有明确的功能/位置在线>>
日期选择器组件
import React from 'react';
import DatePicker from 'material-ui/DatePicker';
/**
* `DatePicker` can be implemented as a controlled input,
* where `value` is handled by state in the parent component.
*/
export default class DateSelect extends React.Component {
constructor(props) {
super(props);
this.state = {
controlledDate: null,
openSnackbar: false,
snackbarText: {
dateconf: 'Date has been entered!'
}
};
}
formatDate(date){
return (date.getMonth() + 1) + "/" + date.getFullYear() + "/" + date.getDate();
} …Run Code Online (Sandbox Code Playgroud)