利用 React,我使用 moment 和 react-datepicker 库设置了一个 DatePicker 组件,并将使用今天的日期以 MM-DD-YYYY 格式计算的初始日期值传递给它。
当我尝试加载时,出现此错误行:
throw new RangeError('时间值无效'); 将系统时区中的日期转换为 UTC+00:00 时区中的相同日期。这样可以确保在实现 UTC 功能时,语言环境将与其兼容。`
日期选择器组件:
class DatePicker extends Component {
render() {
return (
// <input type="date"
// className={this.props.className + " myInput"}
// placeholder={this.props.placeholder}
// onChange={this.props.onChange}
// value={this.props.value}
// />
<DatePicker2
dateFormat="DD MMM YYYY"
className={this.props.className + " myInput"}
selected={moment(this.props.value)}
onChange={this.props.onChange}
readOnly={true}
/>
);
}
}
export default DatePicker;
我的问题是:如何将系统时区中的日期转换为 UTC+00:00 时区中的相同日期(假设这是解决方案,但如果不是,我该如何解决?