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

to-locale-timezone-date

v1.3.2

Published

This is a simple function that converts a GMT date to a date string appended and added with your current system time zone.

Downloads

2

Readme

Convert a date to a string appended with time zone

This is a simple function that converts a GMT date to an ISO date string appended and added with your current system time zone.

Usefull when you want to convert a date to a string and send it to the server. so that when comparing with dates on the server, timezones wont create any issue.

Installation

npm install to-locale-timezone-date

Usage

toLocaleTimezoneDate(date, options)

Example

const { toLocaleTimezoneDate } = require('to-locale-timezone-date'); // for CommonJS require

import { toLocaleTimezoneDate } from 'to-locale-timezone-date'; // for ES6 import

toLocaleTimezoneDate(new Date()) // 2022-12-24T23:02:57+05:30

toLocaleTimezoneDate(new Date('2022-12-24')) // 2022-12-24T05:30:00+05:30

toLocaleTimezoneDate(new Date(), { customOffset: 0 }) // 2022-12-27T00:57:21+00:00

toLocaleTimezoneDate(new Date(), { customOffset: 60 }) // 2022-12-27T00:57:21-01:00

toLocaleTimezoneDate(new Date(), { customOffset: -60 }) // 2022-12-27T00:57:21+01:00

toLocaleTimezoneDate('Some invalid date', { throwInvalidException: true }) // Error: Invalid date

toLocaleTimezoneDate('Some invalid date') // null

Options

{
    throwInvalidException: false // if true, throws an exception when the date is invalid,
    customOffset: null // if set, uses the custom offset instead of the system time zone
}