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 🙏

© 2026 – Pkg Stats / Ryan Hefner

extended-date-formats

v1.0.0

Published

Extend the regular date with extra and useful formats with dayJs

Readme

Date-Formats

When handling dates, many are the times when we are formatting dates from this or that format, or even from one timezone to the other.

Libraries like dayjs are amazing for this task but I got tired of always doing the same job over and over. Oh, and reading the dayjs documentation just to recall how a certain function is done.

This is a wrapper module around the amazing dayjs that allows you to do amazing things with dates without the hustle.

It was built so that it extends the Date object with extra properties so that you can just reference them in your code.

But Why?

When working on the templating modules for cmsish. I needed to create a performant way for templates to render dates in a variety of formats.

For example, a user might want to render an article's date of publication in a variety of ways. With this module, we only need to parse one date and the user can render this date as {~date.short~} or {~date.utc~} or {~date.iso~} or use any of the 14 other formats included!

Show me the code!

Of course first install the module yarn add date.formats

const DF = require('extended-date-formats');

// Initialize with a specific date
let date = DF('2022-10-16T00:45:49.157Z');

// Or with current date
let date = DF(new Date());

// Or let it default to current date
let date = DF();

console.log(date);

This will output all the available formats:

2020-10-16T00:45:49.157Z {
  short: '16/10/2020',
  long: '16th October, 2020',
  local: '10/16/2020 3:45 AM',
  iso: '2020-10-16T00:45:49.157Z',
  utc: '2020-10-16T00:45:49+00:00',
  tz: '2020-10-16T03:45:49+03:00',
  ts: 1602809149,
  tsMs: 1602809149157,
  quarter: '4',
  wk: '42',
  MM: '10',
  MMMM: 'October',
  YY: '20',
  YYYY: '2020'
}

But that's just the beginning, let's now get to the fun stuff:

// when you stringify the date object, it formats into a date string
console.log('stringified:', date + '');
console.log('stringified:', date.toString());

// there is also a short format
console.log('short date:', date.short);
// a localized format
console.log('local date:', date.local);
// with your timezone auto detected via dayjs.tz.guess() 
console.log('timezone', date.tz);
// of you can change to a custom timezone
console.log('custom timezone', date.tz.set('America/New_York'));

// Or as UTC
console.log('utc', date.utc);
// Oh and in case you are curious about the offset
console.log('utc offset', date.utc.offset);
// Or as a local UTC formatted date
console.log('utc local', date.utc.local);

You should see the following in your log:

stringified: Fri Oct 16 2020 03:45:49 GMT+0300 (East Africa Time)
stringified: Fri Oct 16 2020 03:45:49 GMT+0300 (East Africa Time)
short date: 16/10/2020
local date: 10/16/2020 3:45 AM
timezone 2020-10-16T03:45:49+03:00
custom timezone 2020-10-15T20:45:49-04:00
utc 2020-10-16T00:45:49+00:00
utc offset 180
utc local 2022-10-16T04:07:48+03:00

Now get back to eating bacon!