Get date in Node.js [closed]

0

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 !!

    
asked by java005 10.09.2018 в 17:59
source

2 answers

4

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.

    
answered by 10.09.2018 / 18:04
source
0

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.

    
answered by 10.09.2018 в 18:11