npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@goktugcy/timezone-helper

v1.0.1

Published

Timezone Helper is a Javascript library package designed to simplify working with dates and times across different time zones.

Downloads

2

Readme

Timezone Helper

Timezone Helper is a JavaScript library designed to simplify working with dates and times across different time zones. It provides easy-to-use functions for converting and formatting dates and times based on the user's local time zone. This library is useful for any JavaScript application that needs to handle date and time data in a user-friendly manner, whether it's a Node.js backend or a frontend application.

Features

  • Timezone Conversion: Convert timestamps from UTC or any other timezone to the user's local timezone.
  • Flexible Time Formatting: Format dates and times in various formats suitable for display.
  • User-Friendly Date and Time Display: Easily display dates and times in a human-readable format.
  • ISO 8601 Compatibility: Convert dates and times to ISO 8601 format, useful for APIs and data exchange.
  • Current Time Convenience Functions: Quickly access and format the current date and time.
  • Duration Calculation Feature: This feature allows you to calculate the duration between two dates, providing the difference in days, hours, minutes, and seconds. It's especially useful for tracking time intervals or scheduling events.

Installation

Install Timezone Helper using npm:

npm i @goktugcy/timezone-helper

Usage

Here's how you can use Timezone Helper in your project:

  • Convert to Local Timezone
const { convertToUserTimezone } = require("@goktugcy/timezone-helper");

const localTime = convertToUserTimezone(
  "2024-01-20T12:00:00Z",
  "Europe/Istanbul"
);
console.log("Local Time:", localTime);
  • Format Time
const { formatTime } = require("@goktugcy/timezone-helper");

const formattedTime = formatTime(
  "2024-01-20T12:00:00Z",
  "Europe/Istanbul",
  "YYYY-MM-DD HH:mm"
);
console.log("Formatted Time:", formattedTime);
  • Format Current Date
const { formatDate } = require("@goktugcy/timezone-helper");

const currentDate = new Date();
const formattedDate = formatDate(currentDate, "YYYY-MM-DD");
console.log("Formatted Date:", formattedDate);
  • Duration Calculation
const { calculateDuration } = require("@goktugcy/timezone-helper");

// Calculate the duration between two dates
const startDate = "2024-01-01T00:00:00Z"; // Example start date
const endDate = "2024-01-02T12:30:00Z"; // Example end date

// Use the calculateDuration function to calculate the duration
const duration = calculateDuration(startDate, endDate);

// Print the calculated duration
console.log(
  `Duration: ${duration.days} days, ${duration.hours} hours, ${duration.minutes} minutes, ${duration.seconds} seconds.`
);

Note

This package is a minimal package built on momentjs. It will continue to be updated according to needs.