You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't the most elegant solution, but you can do it with the native .toLocaleString() function. You can't set up the arguments for it so that only the timezone name is returned, but you can extract it from the formatted string. Here's a TypeScript example:
exportconstgetShortTimezoneName=(date: Date): string=>{consttimezoneDateStr=date.toLocaleString('en-US',{timeZoneName: 'short',});consttimezoneName=timezoneDateStr.split(' ').pop();if(!timezoneName){thrownewError('Could not parse timezone name');}returntimezoneName;};
Is there a way to get the abbreviation of the current timezone? And specifically, how to determine if in daylight saving? (e.g. EDT or EST)
thanks
The text was updated successfully, but these errors were encountered: