Skip to main content

timezones

codecov deno doc

A list with all the JavaScript possible timezones.

Based on this StackOverflow Question

Usage

Deno πŸš€

import {
  randomTimeZone,
  randomTimeZones,
  timeZones,
} from "https://deno.land/x/timezones/mod.ts";

console.log(`My timezone is ${randomTimeZone()}`);

const date = new Date();

timeZones.forEach((timeZone) => {
  console.log(timeZone, date.toLocaleString("en-US", { timeZone }));
});

// This is a generator function, it will never end, be careful!
for (const timeZone of randomTimeZones()) {
  console.log(timeZone, date.toLocaleString("en-US", { timeZone }));
}

const zonesGenerator = randomTimeZones();

// A safer way to use it
for (let i = 0; i < 10; i++) {
  const { value: timeZone } = zonesGenerator.next();

  date.toLocaleString("en-US", { timeZone });
}

Node.js 🐒

import {
  randomTimeZone,
  randomTimeZones,
  timeZones,
} from "@ultirequiem/timezones";

Browser

You can use any CDN πŸ”₯

Eg. ESM β–Ά SkyPack / Script Tag β–Ά JSDelivr.

The API is the same on all this platforms.

Documentation

Autogenerated Documentation 😎

For more examples checkout Timero and the CLI Tool

CLI

Install

  • Deno πŸŽƒ
deno install https://deno.land/x/timezones/timezones.ts
  • Node.js 🐼
npm install -g @ultirequiem/timezones

Usage

timezones --help

It includes list, random and a fuzzy search command!

A binary for multiple platforms is provided too!

Video Showcase

Support

Open an Issue, I will check it a soon as possible πŸ‘€

If you want to hurry me up a bit send me a tweet πŸ˜†

Consider supporting me on Patreon if you like my work πŸš€

Don’t forget to start the timezones ⭐

Notes

This was done mainly because Timero.

Authors

Eliaz Bobadilla (a.k.a UltiRequiem) - Creator and Maintainer πŸ’ͺ

See also the full list of contributors who participated in this project.

Versioning

We use SemVer for versioning. For the versions available, see the tags.

Licence

Licensed under the MIT License.