Reputation: 235
Currently the date is displayed w/ YYYY first but I would like to put the YYYY at the end.
It looks like this "2022-07-11 @ 3:00PM" but I want it to look like "July, 11th 2022 @ 3:00pm" or at least "07-11-2022 @ 3:00PM"
Here is the current code:
<Text style={styles.centerText}>{gameDataObject.gameDate} @ {gameDataObject.gameStartTime && convertTime(gameDataObject.gameStartTime)}</Text>
</View>```
Upvotes: 0
Views: 65
Reputation: 206
Make use of moment library: https://momentjs.com/docs/
Install it: yarn add moment
Then use it like this:
const initialDate = gameDataObject.gameDate
const formattedDate = moment(initialDate, 'YYYY-MM-DD').format('MMMM, Do YYYY')
FormattedDate will look like what you expect. You can refer further here: https://momentjs.com/docs/#/displaying/
Upvotes: 1