This is a lightweight and timezone-aware date utility package built on top of the powerful Luxon library. It simplifies the handling of complex timezone-based date operations, making it especially useful for global teams managing scheduling across multiple timezones.
Key Features
- Convert date/time between different timezones. (e.g. Asia/Kolkata).
- Get the current time in any timezone. (e.g., Asia/Kolkata)
- Calculate the time difference (in hours) between two timezones.
- Supports for both JavaScript and TypeScript developer.
Installation
You can install the package via npm or yarn.
npm install world-clockify
yarn add world-clockify
Usage
After installation, you can use the library as follows:
import { convertTimeZone, getCurrentTimeInZone, getTimeDifference, formatDateInTimeZone } from 'world-clockify';
const convertedTime = convertTimeZone('2024-01-01T12:00:00', 'America/New_York', 'Europe/London');
console.log(convertedTime);
const currentTime = getCurrentTimeInZone('America/New_York');
console.log(currentTime);
const timeDifference = getTimeDifference('America/New_York', 'Europe/London');
console.log(timeDifference);
const dateStr = '2024-10-14T12:00:00';
const fromZone = 'UTC';
const toZone = 'America/New_York';
const format = 'MM/dd/yyyy HH:mm';
console.log(formatDateInTimeZone(dateStr, fromZone, toZone, format));
Development
See Contributing.
Support
Give a ⭐️ if this project helped you!
You can also sponsor me on Github