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

timestampy

v1.0.0

Published

Bunch of utilities useful when working with UNIX timestamps 🕒

Downloads

4

Readme


Highlights

  • Simple API
  • No dependencies
  • Tree Shakeable
  • Written in TypeScript

Install

npm install timestampy

Usage

import {addHours, toDate} from 'timestampy'

addHours(1546344000, {amount: 3}); //=> 1546354800
toDate(1564146357); //=> '7/26/2019'

API

  • Add
    • addSeconds
    • addMinutes
    • addHours
    • addDays
    • addWeeks
    • addMonths
    • addYears
  • Subtract
    • subtractSeconds
    • subtractMinutes
    • subtractHours
    • subtractDays
    • subtractWeeks
    • subtractMonths
    • subtractYears
  • Is
    • isOlderThan
    • isNewerThan
    • isMinuteOld
    • isHourOld
    • isDayOld
    • isWeekOld
    • isFortnightOld
    • isMonthOld
    • isHalfYearOld
    • isYearOld
    • isOldCustom
  • To
    • toDate
    • toTime
  • Other
    • getCurrentTimestamp
    • howOld

Add

addSeconds(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of seconds you want to add to the timestamp.

addMinutes(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of minutes you want to add to the timestamp.

addHours(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of hours you want to add to the timestamp.

addDays(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of days you want to add to the timestamp.

addWeeks(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of weeks you want to add to the timestamp.

addMonths(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of months you want to add to the timestamp.

addYears(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of years you want to add to the timestamp.

Subtract

subtractSeconds(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of seconds you want to subtract from the timestamp.

subtractMinutes(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of minutes you want to subtract from the timestamp.

subtractHours(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of hours you want to subtract from the timestamp.

subtractDays(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of days you want to subtract from the timestamp.

subtractWeeks(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of weeks you want to subtract from the timestamp.

subtractMonths(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of months you want to subtract from the timestamp.

subtractYears(timestamp, {options})

Returns a modified timestamp.

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

amount

Type: number

The amount of years you want to subtract from the timestamp.

Is

isOlderThan(firstTimestamp, secondTimestamp)

Returns a boolean of whether the firstTimestamp is older than the secondTimestamp.

firstTimestamp

Type: number

UNIX Timestamp.

secondTimestamp

Type: number

UNIX Timestamp.

isNewerThan(firstTimestamp, secondTimestamp)

Returns a boolean of whether the firstTimestamp is newer than the secondTimestamp.

firstTimestamp

Type: number

UNIX Timestamp.

secondTimestamp

Type: number

UNIX Timestamp.

isMinuteOld(timestamp)

Returns a boolean of whether the timestamp is at least minute old (from now).

timestamp

Type: number

UNIX Timestamp.

isHourOld(timestamp)

Returns a boolean of whether the timestamp is at least an hour old (from now).

timestamp

Type: number

UNIX Timestamp.

isDayOld(timestamp)

Returns a boolean of whether the timestamp is at least a day old (from now).

timestamp

Type: number

UNIX Timestamp.

isWeekOld(timestamp)

Returns a boolean of whether the timestamp is at least week old (from now).

timestamp

Type: number

UNIX Timestamp.

isFortnightOld(timestamp)

Returns a boolean of whether the timestamp is at least 2 weeks (from now).

timestamp

Type: number

UNIX Timestamp.

isMonthOld(timestamp)

Returns a boolean of whether the timestamp is at least month old (from now).

timestamp

Type: number

UNIX Timestamp.

isHalfYearOld(timestamp)

Returns a boolean of whether the timestamp is at 6 months old (from now).

timestamp

Type: number

UNIX Timestamp.

isYearOld(timestamp)

Returns a boolean of whether the timestamp is at least year old (from now).

timestamp

Type: number

UNIX Timestamp.

isOldCustom(timestamp, {options})

Returns a boolean of whether the timestamp is at least year old (from now).

timestamp

Type: number

UNIX Timestamp.

options

Type: object

Any of the options below.

time

Type: number

How old the timestamp should be for the function to return true.

To

toDate(timestamp)

Returns a date extracted from timestamp.

timestamp

Type: number

UNIX Timestamp.

toTime(timestamp)

Returns time extracted from timestamp.

timestamp

Type: number

UNIX Timestamp.

Other

getCurrentTimestamp()

Returns a current UNIX timestamp.

howOld(timestamp)

Returns the amount of second of how old the given timestamp is (from now).

timestamp

Type: number

UNIX Timestamp.

License

MIT © Antoni Kepinski

Timestamp icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY