如何将日期从Yyyy/mm/dd更改为React Antive应用中的MM/DD/YYYY?
目前,该日期首先显示为带有YYYY的日期,但我想将Yyyy放在最后。
看起来“ 2022-07-11 @ 3:00 pm”,但我希望它看起来像“ 2022年7月11日 @ 3:00 pm”或至少“ 07-11-2022 @ 3:00 pm”
这是当前的代码:
<Text style={styles.centerText}>{gameDataObject.gameDate} @ {gameDataObject.gameStartTime && convertTime(gameDataObject.gameStartTime)}</Text>
</View>```
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>```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
利用力矩库: https://momentjs.com/docs/
安装它:
yarn添加Moment
然后使用它:
FormattedDate看起来像您期望的。您可以在此处进一步参考: https://momentjs.com/docs/displaying/displaying/
Make use of moment library: https://momentjs.com/docs/
Install it:
yarn add moment
Then use it like this:
FormattedDate will look like what you expect. You can refer further here: https://momentjs.com/docs/#/displaying/