Reputation: 51
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 !
Upvotes: 2
Views: 62
Reputation: 5502
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
Upvotes: 1