ยป npm install date-fns
Videos
Hi everyone, I'm in the process of choosing a date library for our site rewrite, and a long time ago used date-fn, I quite liked the library, so I was going to install it but while navigating the page I got to the sponsors section and there is a lot of casinos and like farms advertising, and by the looks of it, spending big books paying for the space in the front page.
My question is: Is the library safe to use? Or was it compromised?
Sponsors in the pageI managed to run it successfully by using require as shown below:
const fns = require('date-fns')
console.log(fns.format(new Date(), "'Today is a' eeee"))
Update:
I installed node v16.6.1 following the instructions in this answer and now I can run the following code successfully:
import { format } from 'date-fns';
console.log(format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSS"));
You are probably facing syntax errors, as you directly copy pasted the code from the documentation. Try importing the library as follows. It should work just fine.
import { format, formatDistance, formatRelative, subDays } from 'date-fns';
const mDate= format(new Date(2014, 1, 11), 'MM/dd/yyyy');
console.log(mDate);