Modificar la salida de texto de un datetimepicker en react native.!
import React, { Component } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import DateTimePicker from 'react-native-modal-datetime-picker';
import moment from 'moment';
moment.locale('es');
export default class DateTimePickerTester extends Component {
constructor() {
super()
this.state = {
isVisible: false,
chosenDate: '',
selectedDate: '07:00 AM'
}
}
handlePicker = (datetime) => {
this.setState({
isVisible: false,
chosenDate: moment(datetime).format('LLLL')
})
}
hidePicker = () => {
this.setState({
isVisible: false
})
}
showPicker = () => {
this.setState({
isVisible: true
})
}
render() {
return (
<View style={{ flex: 1, alignContent: 'center', justifyContent: 'center' }}>
<Text style={{color:'red', fontSize:20}}>
{this.state.chosenDate}
</Text>
<TouchableOpacity onPress={this.showPicker}>
<Text>Ver</Text>
</TouchableOpacity>
<DateTimePicker
datetime={moment().toDate()}
is24Hour={true}
isVisible={this.state.isVisible}
onConfirm={this.handlePicker}
onCancel={this.hidePicker}
mode={'datetime'}
datePickerModeAndroid={'spinner'}
/>
</View>
);
}
}
obtengo como salida
Wednesday, January 23, 2019 5:37 PM
quiero obtener la fecha en español.