I need to get the system date with date, time, minutes, seconds and milliseconds in node.js and then convert it to an integer.
Any ideas?
Thanks !!
I need to get the system date with date, time, minutes, seconds and milliseconds in node.js and then convert it to an integer.
Any ideas?
Thanks !!
Is this what you want?
let now= new Date();
console.log('La fecha actual es',now);
console.log('UNIX time:',now.getTime());
It is not only from Node, the Date class is standard in any implementation of ECMAScript
For clarification, copy of the MDN website:
The value returned by the method
getTime()
is the number of milliseconds since January 1, 1970 00:00:00 UTC.
You can do it in the following way:
var dat= new Date(); //Obtienes la fecha
var dat2 = Date.parse(dat); //Lo parseas para transformarlo
console.log(dat);
console.log(dat2)
I hope I help you.