Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
pretty-date-js
Advanced tools
To use pretty-date-js first install it from npm npm install pretty-date-js
after module is installed require it in your project
var pretty = require('pretty-date-js');
then just pass date in valid time format
var myPrettyDate = pretty("2012-03-25", options);
{
value: 4,
lang: "years"
}
For date input use valid date format or timestamp e.g.
pretty("Wed Mar 25 2015 01:00:00 GMT+0100 (W. Europe Standard Time)",options);
"1 year ago"
pretty("2015-03-25", options);
"1 year ago"
pretty("JANUARY, 25, 2015", options);
"1 year ago"
pretty("03/25/2016", options);
"2 months ago"
If you are not familiar with date formats please read more here
Use options to override default ENG language settings in module
This is default options object
{
lang: {
seconds: ["second", "seconds"],
minutes: ["minute", "minutes"],
hours: ["hour", "hours"],
days: ["day", "days"],
months: ["month", "months"],
years: ["year", "years"],
misc: ["ago", "Invalid input, please check formating"]
}
}
You can override it with your language to get output like this:
EN 1 hour ago
FR Il y a 1 heure
Enter example folder and run npm install
to install webpack and webpack-dev-server
For development server run npm run start
and open
http://localhost:8080/webpack-dev-server/
in your browser or just run npm run build
for builing example bundle.
To change time in example just update data variable
var date = "2016-06-05T16:00:00";
Please try live demo
FAQs
human-friendly relative date formating lib
The npm package pretty-date-js receives a total of 4 weekly downloads. As such, pretty-date-js popularity was classified as not popular.
We found that pretty-date-js 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.