Bunch of utilities useful when working with UNIX timestamps ๐
- Simple API
- No dependencies
- Tree Shakeable
- Written in TypeScript
npm install timestampy
import {addHours, toDate} from 'timestampy'
addHours(1546344000, {amount: 3}); //=> 1546354800
toDate(1564146357); //=> '7/26/2019'
- 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
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of seconds you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of minutes you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of hours you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of days you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of weeks you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of months you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of years you want to add to the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of seconds you want to subtract from the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of minutes you want to subtract from the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of hours you want to subtract from the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of days you want to subtract from the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of weeks you want to subtract from the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of months you want to subtract from the timestamp.
Returns a modified timestamp.
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
The amount of years you want to subtract from the timestamp.
Returns a boolean
of whether the firstTimestamp
is older than the secondTimestamp
.
Type: number
UNIX Timestamp.
Type: number
UNIX Timestamp.
Returns a boolean
of whether the firstTimestamp
is newer than the secondTimestamp
.
Type: number
UNIX Timestamp.
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least minute old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least an hour old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least a day old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least week old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least 2 weeks (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least month old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at 6 months old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least year old (from now).
Type: number
UNIX Timestamp.
Returns a boolean
of whether the timestamp
is at least year old (from now).
Type: number
UNIX Timestamp.
Type: object
Any of the options below.
Type: number
How old the timestamp should be for the function to return true
.
Returns a date extracted from timestamp.
Type: number
UNIX Timestamp.
Returns time extracted from timestamp.
Type: number
UNIX Timestamp.
Returns a current UNIX timestamp.
Returns the amount of second of how old the given timestamp is (from now).
Type: number
UNIX Timestamp.
MIT ยฉ Antoni Kepinski
Timestamp icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY