I want to change the format date in DD/MM/YYYY, HH:MM if anyone have a idea please? My code:
class Dashboard extends Component {
constructor(props) {
super(props);
this.state = {
sport: {
clubs: [],
},
rival: {
clubs: [],
},
dateMatch: '',
DB: {sound: []},
};
}
call here
<Text
style={{
textAlign: 'center',
marginTop: 30,
fontSize: 18,
backgroundColor: 'rgba (209,209,209, .4)',
}}>
le {element.dateMatch}
</Text>
Thanks for watching !
You can easily do with momentjs package
To install moment on your project run this command
npm install moment --save
Then you can import it in your code
import moment from 'moment';
For date convert, use below example console log
console.log( moment('2018-01-01 13:40:39').format('MM-DD-YYYY hh:mm a') );
Just pass your date value inside moment
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.