DateTimeFormatTimeZone
Surgically polyfills timezone support in Intl.DateTimeFormat
API
![Build Status][] ![NPMRel][]
[Build Status]: https://travis-ci.org/markandey/DateTimeFormatTimeZone.svg?branch=master
[NPMRel]: https://img.shields.io/npm/v/datetimeformattimezone.svg
Some browsers do not support arbitrary time zone in Intl.DateTimeFormat API (becuase its optional to support timezones as per ECMA-402 standard).
This polyfill is to add this support.
new Intl.DateTimeFormat('en', {
timeZone: 'Asia/Calcutta',
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric'
}).format(new Date());
new Intl.DateTimeFormat('en', {
timeZone: 'America/Los_Angeles',
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric'
}).format(new Date());
Install
npm i datetimeformattimezone
Limitation
This pollyfill does not add support for printing timeZone name. This does not mean it breaks standard, Intl.DateTimeFormat
will still behave the same as it would have without this polyfill. Also most uses cases does not include printing timeZone name.