我有一个时间戳
2021-03-12T14:55:35.454Z
我想在ts文件中将其转换为正常时间(如下所示)
下午2时55分
我在Angular工作。如果你们知道了请帮忙。我曾尝试搜索其他stackoverflow问题,但找不到确切的解决方案
如果你们知道了请帮忙
使用Angular的内置Datepipe。
如果要在html中使用它
{{ yourDate| date: 'shortTime'}}
或在组件文件中:
const myDate = new DatePipe('en-US').transform(rawDate,'shortTime' );
rawDate是复杂的时间戳。
要了解有关可用格式的更多信息,请访问https://angular.io/api/common/datepipe