Reputation: 113
Is there a way I can use Angular DatePipe to specify a format that shows "UTC" instead of "GMT". Example Format:
{{currentDate | date:'dd/MM/yyyy hh:mm:ss a (O)'}}
Output: 17/09/2021 10:50:32 AM (GMT-4)
Is there a way I can get the following output instead:
Output: 17/09/2021 10:50:32 AM (UTC-4)
i.e. where it says GMT, the output should say UTC instead
Upvotes: 0
Views: 2024
Reputation: 1491
Since this is purley presentational, and the times of GMT and UTC are always the same, you could create a pipe:
@Pipe({
name: 'utc',
})
export class UtcPipe implements PipeTransform {
transform(dateTime: string): string {
return dateTime.replace('GMT', 'UTC');
}
}
And then the template:
{{ currentDate | date: 'dd/MM/yyyy hh:mm:ss a (O)' | utc }}
I've also added the above answer and it doesn't work.
Upvotes: 1