Abbreviated Timezone for IST/GMT+5:30
See original GitHub issueWhen using the required plugins, the abbreviated timezone is not working for IST. With z
, it shows GMT+5:30
, but with zzz
, it correctly shows Indian Standard Time
.
import { Pipe, PipeTransform } from '@angular/core';
import * as dayjs from 'dayjs';
import * as advancedFormat from 'dayjs/plugin/advancedFormat';
import * as utc from 'dayjs/plugin/utc';
import * as timezone from 'dayjs/plugin/timezone';
@Pipe({
name: 'dayjsTz'
})
export class DayJsDateTimePipe implements PipeTransform {
public transform(value: Date, timeZone?: string, formatting = 'MMM Do YYYY, h:mm a z') {
if (value) {
dayjs.extend(advancedFormat);
dayjs.extend(utc);
dayjs.extend(timezone);
if (timeZone) {
return dayjs.tz(value, timeZone).format(formatting);
}
const userTimeZone = dayjs.tz.guess(); // here it guessed my timezone, Asia/Calcutta. I also tried hardcoding Asia/Kolkata, same result
return dayjs.tz(value, userTimeZone).format(formatting);
}
return value;
}
}
Current Output — Oct 20th 2020, 2:17 pm GMT+5:30
Expected Output — Oct 20th 2020, 2:17 pm IST
- Day.js Version 1.9.3
- OS: macOS Catalina 10.15.7
- Browser Chrome 86 and Safari 14
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:18 (6 by maintainers)
Top Results From Across the Web
List of time zone abbreviations - Wikipedia
Abbr. Name UTC offset
ACDT Australian Central Daylight Saving Time UTC+10:30
ACST Australian Central Standard Time UTC+09:30
ACT Acre Time UTC−05
Read more >Time Zone Abbreviations - Worldwide List - Time and Date
Abbreviation Time zone name Location Offset
A Alpha Time Zone Military UTC +1
ACT Acre Time South America UTC ‑5
ACT Australian Central Time Australia UTC...
Read more >United States Time Zone Abbreviations
United States Time Zone Abbreviations with UTC/GMT Offsets ; AST, ATLANTIC STANDARD TIME, UTC - 4 ; EST, EASTERN STANDARD TIME, UTC -...
Read more >Time Zone Abbreviations for Date and Time Functions
Abbreviation Full Name Registry ID
ACDT Australian Central Daylight Time Cen. Australia Standard Time
ACST Australian Central Standard Time AUS Central Standard Time
AEDT Australian Eastern...
Read more >HLC Time Zone Abbreviations - HealthStream
Abbreviation Description Central LiveMeeting
ET (UTC‑05:00) Eastern Time (US & Canada) US/Eastern America/New York
CT (UTC‑06:00) Central Time (US & Canada) US/Central America/Chicago
MT (UTC‑07:00) Mountain...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems a good choice. I’ll dig it more if I got some time.
hello @iamkun
could you please let me know if this issue/feature is done or maybe in progress? In the doc I see it says we can use
z
for timezone abr https://day.js.org/docs/ru/plugin/advanced-format but it doesnt work.Thank you!