我有一个这种格式的日期:
this.visited_at: "2019-07-26T10:15:00+0200"
我需要忽略时区来显示小时和分钟。
模板:
<p>{{ time.visitedAt | date: 'HH' }} h {{ time.visitedAt | date: 'mm' }}</p>
问题是这会根据机器的时区转换时间。 我需要准确显示 10h15 并忽略所有时区转换。
最佳答案
这可能有效(假设您将始终收到相同格式的日期):
visitedAt = '2019-07-26T10:15:00+0200';
timezone = this.visitedAt.substring(this.visitedAt.length - 5); // Get the timezone
<p>{{ visitedAt | date: 'HH \'h\' mm' : timezone }}</p> <!-- Format the date with the timezone you got from the date -->
关于javascript - Angular - 显示没有时区转换的日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56935845/