
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
human-pretty-date
Advanced tools
human-pretty-date is a Javascript library that helps you collect common and not-so-common informations about your application user.
Use the package manager npm to install human-pretty-date.
npm i human-pretty-date --save
If you are using human-pretty-date with Typescript, you can import the package with the import sintax
import * as humanPrettyDate from 'human-pretty-date';
The usage will be like this:
console.log(formatDate(new Date(new Date() - -2 * 365 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -365 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -2 * 30 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -30 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -2 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -2 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -2 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - -60 * 1000)));
console.log(formatDate(new Date(new Date() - -2 * 1000)));
console.log(formatDate(new Date(new Date() - -1 * 1000)));
console.log(formatDate(new Date()));
console.log(formatDate(new Date(new Date() - 1 * 1000)));
console.log(formatDate(new Date(new Date() - 2 * 1000)));
console.log(formatDate(new Date(new Date() - 60 * 1000)));
console.log(formatDate(new Date(new Date() - 2 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 2 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 2 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 30 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 2 * 30 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 365 * 24 * 60 * 60 * 1000)));
console.log(formatDate(new Date(new Date() - 2 * 365 * 24 * 60 * 60 * 1000)));
This is the complete output:
2 years from now
1 year from now
2 month from now
1 months from now
2 day from now
tomorrow
2 hours from now
1 hour from now
2 minutes from now
1 minute from now
2 seconds from now
1 second from now
just now
1 second ago
2 seconds ago
1 minute ago
2 minutes ago
1 hour ago
2 hours ago
yesterday
2 day ago
1 months ago
2 month ago
1 year ago
2 years ago
To use the i18n provided by the package, you just need to past the desired locale in the config object:
console.log(formatDate(new Date(), { locale: 'pt_BR' })); // agora
Code | Locale |
---|---|
en | English |
pt_BR | Portuguese (Brazil) |
Caio Rolla |
You don't need state management if you use global variables. :bug: |
Pull requests are welcome, specially for new locales. For major changes, please open an issue first to discuss what you would like to change.
This package is based on node-prettydate
FAQs
Format dates for humans
The npm package human-pretty-date receives a total of 106 weekly downloads. As such, human-pretty-date popularity was classified as not popular.
We found that human-pretty-date 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.