
Research
SAP CAP npm Packages Hit by Supply Chain Attack
Compromised SAP CAP npm packages download and execute unverified binaries, creating urgent supply chain risk for affected developers and CI/CD environments.
This is the smallest, fully unit tested module to convert Date objects into human readable relative timestamps, such as '4 minutes ago', 'yesterday', 'tomorrow', or 'in 3 months'. All in 22 lines of TypeScript.
You can optionally specify the maximum unit (eg. hour, day, week) so instead of outputting '2 weeks ago' you will see '14 days ago'.
var ago = require('s-ago');
var now = new Date();
var yesterday = new Date(now.getTime() - (24 * 60 * 60 * 1000));
var hoursAgo = new Date(now.getTime() - (6 * 60 * 60 * 1000));
var yesterday = new Date(now.getTime() - (24 * 60 * 60 * 1000));
var tomorrow = new Date(now.getTime() + (6 * 60 * 60 * 1000));
var inSixHours = new Date(now.getTime() + (6 * 60 * 60 * 1000));
var inTwoWeeks = new Date(now.getTime() + (2 * 7 * 24 * 60 * 60 * 1000));
// present
ago(now); // 'just now'
// past
ago(yesterday); // 'yesterday'
ago(hoursAgo); // '6 hours ago'
// future
ago(inSixHours); // 'in 6 hours'
ago(tomorrow); // 'tomorrow'
// max unit
ago(inTwoWeeks); // 'in 2 weeks'
ago(inTwoWeeks, 'day'); // 'in 14 days'
Output is as follows:
| Time | Output | Future output |
|---|---|---|
| Less than 1 minute | just now | just now |
| 1-2 minutes | a minute ago | in a minute |
| 2-46 minutes | # minutes ago | in # minutes |
| 46 minutes - 2 hours | an hour ago | in an hour |
| 2-20 hours | # hours ago | in # hours |
| 20-48 hours | yesterday | tomorrow |
| 2-6 days | last week | in a week |
| 7-28 days | # weeks ago | in # weeks |
| 28 days - 2 months | last month | in a month |
| 2-11 months | # months ago | in # months |
| 11-23 months | last year | in a year |
| 2+ years | # years ago | in # years |
FAQs
Human readable relative times (eg. 4 minutes ago)
The npm package s-ago receives a total of 42,147 weekly downloads. As such, s-ago popularity was classified as popular.
We found that s-ago demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Research
Compromised SAP CAP npm packages download and execute unverified binaries, creating urgent supply chain risk for affected developers and CI/CD environments.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.