如何将字符串转换为Angular的日期
如何将字符串掩盖到Angular13中的日期?
例如: str ='2022-06-09T22:00:00z';
to datetime mm/dd/yyyy - : - - -
How to covert a string to a date in Angular13?
For example:str = '2022-06-09T22:00:00Z';
to a datetime mm/dd/yyyy --:-- --
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您可以使用库,我建议使用Moment.JS。
这是 link !
首先,由于我们无法从字符串中访问内置函数,因此我们需要将其转换为日期:
使用 moment.js :
使用标准的内置功能:
如果您不希望UTC的时间,只需解决它即可删除它。
If you are okay with using a library, I would recommend to use moment.js.
Here's a link!
Firstly, since we can not access the inbuilt functions from a string, we need to convert it to a date:
Using moment.js:
Using standard in-built functions:
If you don't want the time in UTC, you can simply puzzle it around to remove it.
您可以使用Angular Pipe date
stackblitz
You can use angular pipe date
StackBlitz