# date-fns-timezone

> Parsing and formatting date strings using IANA time zones for date-fns.

Latest version **0.1.4** (published 2018-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install date-fns-timezone
pnpm add date-fns-timezone
yarn add date-fns-timezone
bun add date-fns-timezone
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2018-10-10 |
| First published | 2018-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 2 |
| Unpacked size | 85.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 133 |
| Author | Ferdinand Prantl |
| Maintainers | prantlf |
| Keywords | date-fns, timezone, time-zone, date, time |

## Links

- npm: https://www.npmjs.com/package/date-fns-timezone
- Repository: https://github.com/prantlf/date-fns-timezone
- Homepage: https://github.com/prantlf/date-fns-timezone#readme
- Issues: https://github.com/prantlf/date-fns-timezone/issues
- npm.io page: https://npm.io/package/date-fns-timezone

## Dependencies (2)

- [date-fns](https://npm.io/package/date-fns.md) ^1.29.0
- [timezone-support](https://npm.io/package/timezone-support.md) ^1.5.5

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2018-10-10
- 0.1.3 — 2018-10-07
- 0.1.2 — 2018-10-07
- 0.1.1 — 2018-09-26
- 0.1.0 — 2018-09-19
- 0.0.1 — 2018-09-18

## README

# date-fns-timezone
[![NPM version](https://badge.fury.io/js/date-fns-timezone.png)](http://badge.fury.io/js/date-fns-timezone)
[![Build Status](https://travis-ci.org/prantlf/date-fns-timezone.png)](https://travis-ci.org/prantlf/date-fns-timezone)
[![Coverage Status](https://coveralls.io/repos/github/prantlf/date-fns-timezone/badge.svg?branch=master)](https://coveralls.io/github/prantlf/date-fns-timezone?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4bb0f2ef6c1b4212a4ed2dbf1f3e8b29)](https://www.codacy.com/app/prantlf/date-fns-timezone?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=prantlf/date-fns-timezone&amp;utm_campaign=Badge_Grade)
[![Dependency Status](https://david-dm.org/prantlf/date-fns-timezone.svg)](https://david-dm.org/prantlf/date-fns-timezone)
[![devDependency Status](https://david-dm.org/prantlf/date-fns-timezone/dev-status.svg)](https://david-dm.org/prantlf/date-fns-timezone#info=devDependencies)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

Provides parsing and formatting date strings and time zone conversions supporting [IANA time zones], following the design of functions in [date-fns]. List of canonical time zone names is provided by [timezone-support].

### Table of Contents

- [Synopsis](#synopsis)
- [Installation and Getting Started](#installation-and-getting-started)
- [Usage Scenarios](./docs/usage.md#usage-scenarios)
- [API Reference](./docs/API.md#api-reference)
- [Contributing](#contributing)
- [Release History](#release-history)
- [License](#license)

## Synopsis

```js
const { listTimeZones } = require('timezone-support')
const { parseFromTimeZone, formatToTimeZone } = require('date-fns-timezone')

// List canonical time zone names: [ 'Africa/Abidjan', ... ]
const timeZones = listTimeZones()

// Set the date to "2018-09-01T16:01:36.386Z"
const date = parseFromTimeZone('2018-09-01 18:01:36.386', { timeZone: 'Europe/Berlin' })

// Set the output to "1.9.2018 18:01:36.386 GMT+02:00 (CEST)"
const date = new Date('2018-09-01Z16:01:36.386Z')
const format = 'D.M.YYYY HH:mm:ss.SSS [GMT]Z (z)'
const output = formatToTimeZone(date, format, { timeZone: 'Europe/Berlin' })
```

## Installation and Getting Started

This module can be installed in your project using [NPM] or [Yarn]. Make sure, that you use [Node.js] version 6 or newer.

```sh
$ npm i date-fns-timezone --save
```

```sh
$ yarn add date-fns-timezone
```

Functions are exposed as named exports from the package modules, for example:

```js
const { parseFromTimeZone, formatToTimeZone } = require('date-fns-timezone')
```

You can read more about the [module loading](./docs/API.md#loading) in other environments, like with ES6 or in web browsers. [Usage scenarios](./docs/usage.md#usage-scenarios) demonstrate applications of this library in typical real-world scenarios. The [API reference](./docs/API.md#api-reference) lists all functions with a description of their functionality.

## Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.  Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

## Release History

* 2018-10-10   v0.1.4   Fix compatibility with IE. Thanks, [Andrii](https://github.com/AndriiDidkivsky)!
* 2018-10-06   v0.1.2   Add TypeScript export declarations.
* 2018-09-19   v0.1.0   Add parseString without a time zone to cover a gap in date-fns
* 2018-09-17   v0.0.1   Initial release

## License

Copyright (c) 2018 Ferdinand Prantl

Licensed under the MIT license.

[IANA time zones]: https://www.iana.org/time-zones
[date-fns]: https://github.com/date-fns/date-fns
[timezone-support]: https://github.com/prantlf/timezone-support
[Node.js]: http://nodejs.org/
[NPM]: https://www.npmjs.com/
[Yarn]: https://yarnpkg.com/
[RequireJS]: https://requirejs.org/

---
_Source: https://npm.io/package/date-fns-timezone · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
