time-converter-by-timezone
TypeScript icon, indicating that this package has built-in type declarations

2.3.2 • Public • Published

time-converter-by-timezone

Convert Timezone is a lightweight npm package that simplifies the process of converting time from one timezone to another. Whether you need to convert from Current timezone time to Australia/Perth or any other timezone, this package handles the conversion seamlessly. Simply input the current timezone time and the target timezone, and Convert Timezone will provide the equivalent time in the desired timezone, making timezone conversions hassle-free.

Install package using npm

npm i time-converter-by-timezone

Install package using yarn

yarn add time-converter-by-timezone

Usage

Convert current timezone date to target timezone date

// Note: Current timezone will pick automatically

import { convertTimeToTargetTimezone } from "time-converter-by-timezone";

const time = convertTimeToTargetTimezone(
	"02/25/2024, 11:00:00 AM", // You can pass time as you want in any date format
	"Australia/Perth" // Target timezone
);
console.log("time: ", time);
// time: 2024-02-25T03:00:00.000Z
console.log("Local string: ", new Date(time).toLocaleString());
// Local string: 25/2/2024, 8:30:00 am

// Australia/Perth timezone is 2:30 hours ahead of Asia/Calcutta timezone
// Hence when 8:30 AM Asia/Calcutta equals to 11 AM Australia/Perth time

Convert date to one timezone to target timezone date. You can get date/time that refers target timezone

import { oneTimezoneToTargetTimezone } from "time-converter-by-timezone";

const time = oneTimezoneToTargetTimezone(
	"02/25/2024, 11:00:00 AM", // You can pass time as you want in any date format
	"Asia/Calcutta", // You can mention your timezone
	"Australia/Perth" // Target timezone
);
console.log("time = ", time);
// time: 2024-02-25T03:00:00.000Z
console.log("Local string = ", new Date(time).toLocaleString());
// Local string: 25/2/2024, 8:30:00 am

// Australia/Perth timezone is 2:30 hours ahead of Asia/Calcutta timezone
// Hence when 8:30 AM Asia/Calcutta equals to 11 AM Australia/Perth time

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.3.21latest

Version History

VersionDownloads (Last 7 Days)Published
2.3.21
2.3.10
2.3.00
2.2.30
2.2.20
2.2.12
2.2.01
2.1.21
2.1.11
2.1.01
2.0.71
2.0.62
2.0.50
2.0.40
2.0.32
2.0.20
2.0.10
2.0.00
1.1.10
1.1.00
1.0.00

Package Sidebar

Install

npm i time-converter-by-timezone

Weekly Downloads

12

Version

2.3.2

License

ISC

Unpacked Size

5.14 kB

Total Files

5

Last publish

Collaborators

  • jayspatel2962