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

last-seen-ago

v1.1.0

Published

highly customizable real time to last seen like facebook,twitter,whatsap...

Downloads

47

Readme

last-seen-ago

npm version

last-seen-ago is a zero-dependency module that highly customizable real time to last seen like Facebook,Twitter,Instagram...

It is a simple one line code ,Its automatically converts to given timestamp in the right units like seconds, minutes, hours, days,weeks, years using getLastSeen() method.

Examples:

  • Juts Now
  • 45 seconds
  • one minute ago
  • 15 minutes ago
  • an hour ago
  • 2 hrs ago
  • yesterday
  • 2 days ago
  • a week ago
  • 2 weeks ago

Installation

npm install last-seen-ago --save

Usage

As early as possible in your application, require and configure last seen.Check it following Rules.

###getLastSeen()

//require last-seen-ago module
const lastSeenAgo = require("last-seen-ago");

//for example your real time timestamp 1602050284
const realTime = 1602050284;

//get exact last seen according to time
const lastSeen = lastSeenAgo.getLastSeen(realTime)

//print output will be "34 minutes ago"
console.log(lastSeen)

Rules

The parsing timstamp support the following rules:

  • To timestamp value should be double data type.
  • To get the timestamp as seconds. For example
    • To get the timestamp Date.now() method can be called.
    • Note that this method returns the timestamp in milliseconds.
    • To get the timestamp as seconds we can divide it by 1000.

Given are the following formats:

  • Format type 1 with backslashes (/) as the separator characters.
  • Format type 2 with dashes (-) as the separator characters.
  • Format type 3 with dots (.) as the separator characters.
  • Format type 4 with spaces ( ) as the separator characters.

Type | Example ---- | ------- YYYY-MM-DD or yyyy-mm-dd | 2020-10-12 YYYY-DD-MM or YYYY-DD-MM | 2020-12-10 MM-DD-YYYY or mm-dd-yyyy | 10-12-2020 DD-MM-YYYY or DD-MM-YYYY | 12-10-2020 YYYY-MM-DD HH:MM:SS or yyyy-mm-dd hh:mm:ss | 2020-10-12 11:26:1 YYYY-DD-MM HH:MM:SS or YYYY-DD-MM hh:mm:ss | 2020-12-10 11:26:1 MM-DD-YYYY HH:MM:SS or mm-dd-yyyy hh:mm:ss | 10-12-2020 11:26:1 DD-MM-YYYY HH:MM:SS or DD-MM-YYYY hh:mm:ss | 12-10-2020 11:26:1 YYYY.MM.DD or yyyy.mm.dd | 2020.10.12 YYYY.DD.MM or YYYY.DD.MM | 2020.12.10 MM.DD.YYYY or mm.dd.yyyy | 10.12.2020 DD.MM.YYYY or DD.MM.YYYY | 12.10.2020 YYYY.MM.DD HH:MM:SS or yyyy.mm.dd hh:mm:ss | 2020.10.12 11:26:1 YYYY.DD.MM HH:MM:SS or YYYY.DD.MM hh:mm:ss | 2020.12.10 11:26:1 MM.DD.YYYY HH:MM:SS or mm.dd.yyyy hh:mm:ss | 10.12.2020 11:26:1 DD.MM.YYYY HH:MM:SS or DD.MM.YYYY hh:mm:ss | 12.10.2020 11:26:1 YYYY/MM/DD or yyyy/mm/dd | 2020/10/12 YYYY/DD/MM or YYYY/DD/MM | 2020/12/10 MM/DD/YYYY or mm/dd/yyyy | 10/12/2020 DD/MM/YYYY or DD/MM/YYYY | 12/10/2020 YYYY/MM/DD HH:MM:SS or yyyy/mm/dd hh:mm:ss | 2020/10/12 11:26:1 YYYY/DD/MM HH:MM:SS or YYYY/DD/MM hh:mm:ss | 2020/12/10 11:26:1 MM/DD/YYYY HH:MM:SS or mm/dd/yyyy hh:mm:ss | 10/12/2020 11:26:1 DD/MM/YYYY HH:MM:SS or DD/MM/YYYY hh:mm:ss | 12/10/2020 11:26:1 YYYY MM DD or yyyy mm dd | 2020 10 12 YYYY DD MM or YYYY DD MM | 2020 12 10 MM DD YYYY or mm dd yyyy | 10 12 2020 DD MM YYYY or DD MM YYYY | 12 10 2020 YYYY MM DD HH:MM:SS or yyyy mm dd hh:mm:ss | 2020 10 12 11:26:1 YYYY DD MM HH:MM:SS or YYYY DD MM hh:mm:ss | 2020 12 10 11:26:1 MM DD YYYY HH:MM:SS or mm dd yyyy hh:mm:ss | 10 12 2020 11:26:1 DD MM YYYY HH:MM:SS or DD MM YYYY hh:mm:ss | 12 10 2020 11:26:1

Some Short formats

Type | Example ---- | ----- Y/m/d H:m:s | 2020/10/12 11:26:1 Y/d/m H:m:s | 2020/12/10 11:26:1 m/d/Y H:m:s | 10/12/2020 11:26:1 d/m/Y H:m:s | 12/10/2020 11:26:1 Y-m-d H:m:s | 2020-10-12 11:26:1 Y-d-m H:m:s | 2020-12-10 11:26:1 m-d-Y H:m:s | 10-12-2020 11:26:1 d-m-Y H:m:s | 12-10-2020 11:26:1 Y.m.d H:m:s | 2020.10.12 11:26:1 Y.d.m H:m:s | 2020.12.10 11:26:1 m.d.Y H:m:s | 10.12.2020 11:26:1 d.m.Y H:m:s | 12.10.2020 11:26:1

###getFormat()

//require last-seen-ago module
const lastSeenAgo = require("last-seen-ago");

//if timestamp in 1602495292171(miliseconds),then converts timestamp in seconds divide it by 1000.
const realTime = 1602495292171;

//if timestamp in 1602495292 (seconds).
const realTime = 1602495292;

//get exact last seen according to timestmap and specific format.
const lastSeen = lastSeenAgo.getFormat(realTime,'YYYY-MM-DD')

//print output will be 2020-12-10"
console.log(lastSeen)

Future Plan

More features added soon like.

License

MIT