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

timezone-lib

v1.0.4

Published

timezone library give you almost all county or region date and time.

Downloads

11

Readme

timezone-lib library give you almost all county or region date and time, please check below for more.


✔ How to Install

using npm | yarn | pnpm command, you can install timezone-lib library.

npm install timezone-lib
yarn add timezone-lib
pnpm add timezone-lib

💢 How to Import

# using ES6+ (module-js approach)
import { TimeZone } from "timezone-lib"

or

# using ES5 (common-js approach)
const { TimeZone } = require("timezone-lib")

A full-featured timezone aware date and time, or formatter for JavaScript.

  • timezone-lib is a library in pure JavaScript with no dependencies that provides timezone aware date and time formatting or more.

  • timezone formats dates with a full implementation of formats, by default all are set indian timezone.

  • timezone-lib offer fully secure and strict type safety.


😎 Examples

import { TimeZone } from 'timezone-lib';
const timezone = new TimeZone();

All Timezones List

const allTimezones = timezone.allTimezones();
console.log(allTimezones);

Output: [
  'Asia/Calcutta',
  'America/New_York',
  ...
]

Current Date And Time By TimeZone

const dateTimeInfo = timezone.currentDateAndTimeByTimeZone('Asia/Calcutta');
console.log(dateTimeInfo);

Output: {
  date_and_time: '23/12/2023, 03:30:00 PM',
  date: '23/12/2023',
  time: '03:30:00 PM'
}

Current Date And Time Of All TimeZone

const allDateTimeInfo = timezone.currentDateAndTimeOfAllTimeZone();
console.log(allDateTimeInfo);

Output: {
  'Asia/Calcutta': {
    date_and_time: '12/23/2023, 10:30:00 AM',
    date: '12/23/2023',
    time: '10:30:00 AM' },
    ...
}

Separated Current Date And Time By TimeZone

const dateTimeInfo = timezone.separatedCurrentDateAndTimeByTimeZone('Asia/Calcutta');
console.log(dateTimeInfo);

Output: {
  date_and_time: '12/23/2023, 10:30:00 AM',
  date: '12/23/2023',
  time: '10:30:00 AM'
}

Separated Current Date And Time Of All TimeZone

const allDateTimeInfo = timezone.separatedCurrentDateAndTimeOfAllTimeZone();
console.log(allDateTimeInfo);

Output: {
  'Asia/Calcutta': {
    date_and_time: '12/23/2023, 10:30:00 AM',
    date: '12/23/2023',
    time: '10:30:00 AM' },
    ...
}

Time Since

const elapsed = timezone.timeSince(new Date('2023-01-01T00:00:00'));
console.log(elapsed);

Output: 'about 11 months';

Get Expiration Date

const expirationInfo = timezone.getExpirationDate(1672531199000);
console.log(expirationInfo);

Output: 'about 1 day';

Format Date And Time

const formattedDateTime = timezone.formatDateAndTime(new Date(), true);
console.log(formattedDateTime);

Output: {
  date: '2023-12-23',
  time: '15:30:00'
}

Date Format

const formattedDate = timezone.dateFormat(new Date(), 'medium', 'fr-FR');
console.log(formattedDate);

Output: '23 déc. 2023';

Get Date And Time in GMT ISO UTC

const gmtIsoUtcInfo = timezone.getDateAndTimeInGmtIsoUtc(new Date());
console.log(gmtIsoUtcInfo);

Output: {
  GMT: 'Sat, 23 Dec 2023 15:30:00 GMT',
  ISO: '2023-12-23T15:30:00.000Z',
  UTC: '2023-12-23 15:30:00 UTC'
}

☯ License

MIT License