Ling Vu
Ling Vu

Reputation: 5181

How to escape letters in Angular Date pipe?

I want to ask something might already exists here on SO. However none of them really helped me so far. So I decided you ask this question in order to hopefully find an answer to it:

I want to put in the format as string and escape the h letter as you can see, but for some reason this does not work and it shows me a number.

<span>{{ comment?.last_modified_at | date : 'MMM d · HH:mm U\hr' }}</span>

I need this format string as a whole and cannot put it outside or any other manipulation of the date afterwards.

Hope you can help. Thanks a lot for your understanding.

Sources: https://angular.io/api/common/DatePipe

Upvotes: 0

Views: 521

Answers (2)

user17097243
user17097243

Reputation: 21

{{comment?.last_modified_at | date: 'HH:mm:ss \'Uhr\'' }} gives you the expected output and keeps the term "Uhr" (which means "o clock" in German) readable / searchable in the code.

Upvotes: 0

Akhil
Akhil

Reputation: 1453

Please update your code to the following ::

<span>{{comment?.last_modified_at | date : 'MMM d · HH:mm U\'h\'r' }}</span>

Upvotes: 1

Related Questions