如何将日期,时间和日期与react Native代码中的标题分开?
let d = new Date(item.starts_on);
let date = `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;
let time = `${d.getHours()}:${d.getMinutes()}`;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以这样做,使用 dayjs 通过使用它,您可以处理日期并转换为许多不同的形状信息检查它们的文件)。 如果您想将日期和时间与时间戳分开
例如, 日期,您可以:
更新答案
对于将日期转换为“ 2022年3月19日星期六”,您想要的,以下内容以下内容:
There are two approach for doing it, first way (that is easier) using packages like moment or dayjs by using it you are be able to handle date and convert to many different shapes (for more information check the documents of them). For example if you want to separate date and time from a timestamp you can do it by moment like below:
Second way is using at instance of Date, for doing it you can:
Update Answer
For converting date to like "Sat 19 Mar 2022" you want, followings below: