World-Clockify
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. (e.g., 'America/New_York', 'Europe/London');
- Supports both JavaScript and TypeScript
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));