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

human-readable-time

v0.3.0

Published

Human readable date-time

Downloads

34

Readme

Convert Date to format given by pattern

Test status

Examples

var hrt = require('human-readable-time');

console.log(hrt(new Date(0), '%hh%:%mm%'));
// -> 00:00

console.log(hrt(new Date(0), 'Now is %YYYY% year'));
// -> Now is 1970 year

// Default pattern
console.log(hrt(new Date(0)));
// -> 00:00 01/01/1970

// Day/month string patterns
console.log(hrt(new Date(0), 'Today is %day%'));
// -> Today is Thursday

// Relative pattern
console.log(hrt(new Date(0), '%relative% ago'));
// -> 45 years ago

Currying is also supported!

var hrt = require('human-readable-time');

// You can use date, pattern and both in constructor
var clock = new hrt('hh:mm');

console.log(clock(new Date(0)));
// -> 00:00

Docs

|Symbol|Meaning| |:---:|-------| | h | hours | | m | minutes | | s | seconds | | D | day of month | | M | month | | YY | year | | day | day of week | | month | month of year | | relative | relative time | | 12h | Force AM/PM position |

Symbols can be used twice, it will add 0 if number less than 10, for example:

console.log(hrt(new Date(1000) '%s%'));
// -> 1

console.log(hrt(new Date(1000) '%ss%'));
// -> 01

But year can only be used in %YY% or %YYYY% variants.

Options

  • shortDay - Return first 3 letters of day for %day% pattern
  • shortTime - Return time in 12-hour format(you can specify %12h% option to force using 'PM'/'AM' in specific place)

License

MIT © Konstantin Azizov