
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
unix-timestamp
Advanced tools
Tiny library to create and manipulate Unix timestamps in Javascript. (A Unix timestamp is the number of seconds elapsed since Unix epoch time, i.e. January 1 1970 00:00 UTC.)
npm install unix-timestamp
Then:
const timestamp = require('unix-timestamp');
.now([offset])
gives the current time, optionally applying an offset (see below).fromDate(dateOrString)
gives the time from a Javascript Date object or an ISO 8601 date string.toDate(time)
correspondingly gives the date from a timestamp.add(time, offset)
applies an offset to the given time.duration(offset)
gives the offset timestamp for the given offset stringAn offset can be either a number (unit: seconds) or a string with format [+|-] [{years}y] [{months}M] [{weeks}w] [{days}d] [{hours}h] [{minutes}m] [{seconds}s] [{milliseconds}ms]
(for example -30s
).
The actual values (in seconds) used for each unit of time in an offset string are exposed by properties .Millisecond
, .Second
, .Minute
, .Hour
, .Day
, .Week
, .Month
(i.e. mean Gregorian month) and .Year
.
By default timestamps include decimals (fractions of a second). You can set the lib to round all returned timestamps to the second with timestamp.round = true
.
npm test
runs the tests with Mocha.
npm run test-cover
runs the tests and outputs coverage stats with Istanbul.
npm run license
updates license information with source-licenser.
The code follows the Semi-Standard style.
FAQs
Tiny library to create and manipulate Unix timestamps
The npm package unix-timestamp receives a total of 20,533 weekly downloads. As such, unix-timestamp popularity was classified as popular.
We found that unix-timestamp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.