Author: | Hexagon |
---|---|
Views Total: | 62 views |
Official Page: | Go to website |
Last Update: | November 3, 2023 |
License: | MIT |
Preview:

Description:
A lightweight JavaScript utility script that allows you to transform any date into another timezone and vice versa.
This means you can use this script to format and parse dates using timezones. Works in Node.js, Deno, and modern browsers.
How to use it:
1. Install and download.
# NPM $ npm i minitz
2. Import the minitz.js.
// ES import minitz from "minitz"; // CommonJS const minitz = require("minitz"); // Browser <script src="./dist/minitz.min.js"></script> // CDN <script src="https://cdn.jsdelivr.net/npm/minitz/dist/minitz.min.js"></script>
3. Convert the date to another time zone.
timeInNewYork = minitz.toTZ(new Date(), "America/New_York");
4. Convert the date to local time zone.
const localTime = minitz(y,m,d,h,i,s, "Canada/Mountain"); // use ISO8601 strings const localTime = minitz.fromTZISO("2022-09-15 23:00:00", "Canada/Mountain");
5. It also allows creating faux dates from TimePoint.
minitz.fauxDate(timeInNewYork)
Changelog:
v4.0.6 (12/03/2023)
- Fixes bug making dates with AKDT offsets result in Invalid Date
v4.0.5 (03/09/2023)
- Bugfix
v4.0.4 (11/28/2022)
- Bugfix
v4.0.3 (11/14/2022)
- Code cleanup
v4.0.2 (11/13/2022)
- fix: JSC support
v4.0.1 (10/30/2022)
- Fixes rare bug showing in some DST transitions
v4.0.0 (10/08/2022)
- breaking: Change timepoint interface, second -> s etc.
v3.0.0 (09/24/2022)
- breaking: Stop exporting non minified cjs to npm
- fix: Use Date.parse instead of custom ISO8601 parsing function
v2.1.1 (09/17/2022)
- Bugfix
v2.1.0 (09/15/2022)
- Code cleanup
- Add .toTZISO(…) for using ISO8601 formatted time string
v2.0.0 (09/14/2022)
- Add shortcut to convert from a specific timezone to local minitz(y,m,d,h,i,s,tz);
- Introduce TimePoint object instead of faux dates
- Allow creating faux dates from TimePoint using new function minitz.fauxDate()