
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
A lose implementation of Golang's Time.format method.
It's (mostly) a single function to format a date after a given
string that describes what the format should look like, using a specific date: Mon Jan 2 15:04:05 2006 and pm to describe am/pm.
The library currently does not care for timezones. Sorry. PRs welcome.
var niceTime = require('nice-time')
var date = new Date('2017-06-21 16:45:57')
date.toString()
'Wed Jun 21 2017 16:45:57 GMT+0200 (CEST)'
// Simple date
niceTime('Mon Jan 2 15:04:05 2006', date)
'Wed Jun 21 16:45:57 2017'
// For the people across the pond
niceTime('Mon Jan 2 3:04pm 2006', date)
'Wed Jun 21 4:45pm 2017'
// Formatting <3
niceTime('On the second day of the month at the fifteenth hour', date)
'On the twentyfirst day of the month at the sixteenth hour'
// You can prepend numbers with 0, _ or nothing for different formats.
niceTime('Hour: "3"', date)
'Hour: "4"'
niceTime('Hour: "03"', date)
'Hour: "04"'
niceTime('Hour: "_3"', date)
'Hour: " 4"'
// You can also add patterns.
niceTime.addPattern({
pattern: 'MANY SECONDS',
get: function (d, lang) {
return d.getTime()
}
})
niceTime('This is now: MANY SECONDS', date)
This is now: 1498056357000'
Notice that the last example takes a lang argument. The lang argument
contains the object defined in lang/en.json, and can be changed at will if
you have your own lang file by giving providing it to the format function as
a third parameter:
var da = require('./lang/da.json') // because I created my own
niceTime('Minutes: 4th', date, en)
'Minutes: femogfyrrende' // "fourtyfifth" in Danish
FAQs
Lose implementation of Golang's time.format
We found that nice-time 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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.