# set-tz

> sets the timezone for your short-lived node.js process in any OS-Windows too

Latest version **0.2.0** (published 2019-06-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install set-tz
pnpm add set-tz
yarn add set-tz
bun add set-tz
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2019-06-05 |
| First published | 2017-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/set-tz) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | capajj@gmail.com |
| Maintainers | capaj |
| Keywords | timezone, tzutil, time, date, date, offset, testing |

## Links

- npm: https://www.npmjs.com/package/set-tz
- Repository: https://github.com/capaj/set-tz
- Homepage: https://github.com/capaj/set-tz#readme
- Issues: https://github.com/capaj/set-tz/issues
- npm.io page: https://npm.io/package/set-tz

## Dependencies (1)

- [windows-iana](https://npm.io/package/windows-iana.md) ^3.0.0

## 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.2.0 (latest) — 2019-06-05
- 0.1.0 — 2018-03-16
- 0.0.3 — 2017-01-10
- 0.0.2 — 2017-01-10
- 0.0.1 — 2017-01-10

## README

# set-tz

sets the timezone for your node.js process across all OSes

## sample usage

```javascript
const setTZ = require('set-tz')
setTZ('UTC')
// that's it
```

It will even convert between operating systems

```javascript
const setTZ = require('set-tz')
setTZ('America/New_York')
```

This will set timezone to America/New_York in non-Windows environments.
In Windows environments, it will set the timezone to Eastern Standard Time (because Windows doesn't respect IANA timezones).

## Jest usage

It is very common you want to run all your tests in UTC no matter which timezone your computer is in. If you need that, then you can use a shortcut:

```
  "jest": {
    "setupFiles": ['set-tz/utc']
  }
```

## Windows caveat

On windows, when you call `setTZ()` it effectively changes your whole OS timezone so beware-if you kill the process, you'll need to manually revert back after you're done-I am assuming you'r process is short-lived. If you don't kill your process, it will revert your original timezone back for you.

On all other OSes, it just sets `process.env.TZ`, so beware that the current process won't have the timezome set. Only it's children.

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