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

readable-timestamp-js

v1.0.2

Published

Helping user reduce time to create a human readable timestamp format

Downloads

7

Readme

Get a Readable, formatted and customized timestamp

If you want to quickly set up a customized timestamp format, this might be the easiest way.

Install

$ npm install readable-timestamp-js

Usage

ES6(preferred)

import { timeDifferenceForDate, readableTimestamp } from "readable-timestamp-js";

or

const { timeDifferenceForDate, readableTimestamp } = require("readable-timestamp-js")

function timeDifferenceForDate()

timeDifferenceForDate accept 1 parameter, help users to calculate the difference between previous time and current time and return a human readable string.

const date = new Date();
console.log(timeDifferenceForDate(date))

//=> Just now

const previous = "Sun Jul 03 2022 00:37:36 GMT+0000"
console.log(timeDifferenceForDate(previous))

//=> 2 months ago

Readable patterns

  • Just now
  • Less than 1 min ago
  • 1 min ago | mins ago
  • 1 hour ago | hours ago
  • 1 day ago | days ago
  • 1 month ago | months ago
  • 1 year ago | years ago

function readableTimestamp()

readableTimestamp can accept 3 parameter and return a string to help users creating various date formats easily.

####1. The first parameter is the timestamp.

const date = new Date()
readableTimestamp(date)

//=> 02-07-2022 at 20:37

####2. The second parameter is a string to describe your format.

const date = new Date()
readableTimestamp(date, "at h:m")
//=> at 20:37
readableTimestamp(date, "h:m, M/D/Y")
//=> 20:37, 07/02/2022
readableTimestamp(date, "D/M, h:m ")
//=> 02/07, 20:37

Patterns roles

  1. upperCase
  • Y : return year
  • M : return month
  • D : return day
  1. lowerCase
  • h : return hour
  • m : return minute ** case sensitive!!**
  1. others It will return all the rests of your string including spaces and special characters.

  2. Remeber the basic role, and you can write your pattern in any combination!

####3. The third parameter is a string to change your month to English.

const date = new Date()
readableTimestamp(date, "D M, Y at h:m", "month")
//=> 02 Jul, 2022 at 20:37

Author

Yik