Reputation: 947
In my Angular project, I have a table with a timestamp column. Its data is being filled with an HTTP request to the server.
The format in which the server sends back the timestamp is this: 2020-10-13T12:09:42.9762
I'm trying to use the timezone
parameter from the angular date pipe to format my date and show it in Iran standard time which is UTC + 3:30 like so,
<tr *ngFor="let row of tableData; let i = index">
<td>
{{ row.timeStamp | date: 'short':'+0330' }}
</td>
</tr>
But it's not working. Only the short
part is working in the pipe. The +0330
part is not doing anything.
Can anyone tell me what I'm doing wrong? or suggest an alternative way for converting this UTC date and time 2020-10-13T12:09:42.9762
to Iran Standard Time (IRST)? which is UTC+03:30 by the way.
Upvotes: 0
Views: 569
Reputation: 622
Just need add UTC designator in the end of your original date and no need to set timezone in angular date pipe
Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator ("Z")
{{ '2020-10-13T12:09:42.9762Z' | date:'short' }
if you need more information you can see date format specification of w3 w3 time format specification
Upvotes: 1