This library provides utilities for converting between different timezones. It is designed to be simple, efficient, and easy to integrate into your projects.
- Get the time current time in specific timzone
- DST support
- Support for all major timezones
- Easy-to-use API
To install the library, use the following command:
npm install zone_converter
Here is a basic example of how to use the library:
const { getCurrentTimeFromTimezone } = require("zone_converter");
// Convert time from UTC to EST
const berlinTime = getCurrentTimeFromTimezone("Europe/Berlin", false);
console.log(berlinTime); // Output: 2024-10-24T15:56:24.722Z
You can get a list of all available cities and timezones by using the following:
const { getAllTimezones } = require("zone_converter");
const timezones = getAllTimezones();
console.log(timezones); // Output: ["Europe/Berlin", "America/New_York", ...]
Returns a Date
object based on the provided timezone.
timezone
: The timezone identifier (e.g., "Europe/Berlin").isDST
: Boolean indicating whether Daylight Saving Time is in effect.
Returns the offset from UTC based on the provided timezone.
timezone
: The timezone identifier (e.g., "Europe/Berlin").isDST
: Boolean indicating whether Daylight Saving Time is in effect.
Returns a Date
object based on the provided offset from UTC.
offset
: The offset in hours from UTC.
Returns a list of timezones in the provided continent.
continent
: The name of the continent (e.g., "Europe").
Returns a formatted string of a Date
object.
time
: TheDate
object to format.is24Hours
: Boolean indicating whether to use 24-hour format.
Returns a boolean if provided timezone is in Daylight savings time. Note: Will also return false if the timezone doesn't participate in DST
timezone
: The timezone identifier (e.g., "Europe/Berlin").
Enable debug logging with TZ_DEBUG=true
.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or issues, please open an issue on the GitHub repository.