react-native - 我在 react native 中使用 react-native calendar-picker。我想要日期格式 DD/MM/YYYY 作为输出
问题描述
从“时刻”导入时刻;
const { selectedStartDate } = this.state;
const startDate = selectedStartDate ? selectedStartDate.toString() : '';
const maxDate = moment(selectedStartDate, 'DD-MM-YYYY').format();
我得到的输出是 2021 年 2 月 8 日星期一 12:00:00 GMT+0530
2021-02-08T12:00:00+05:30
解决方案
像这样试试
const maxDate = moment(selectedStartDate).format('DD/MM/YYYY');