-2

Hello i want to get current time as 00/00/0000 00:00:00 with javascript ?

00/00/0000 00:00:00

is it possible or must to use a library

SUPERMAN
  • 9
  • 1
  • 4

2 Answers2

1
var date = new Date();

console.log(`${date.toLocaleDateString()} ${date.toLocaleTimeString()}`);
ilia
  • 339
  • 8
  • 23
0

Plain JavaScript provides the Date() object which returns that information.

var date=new Date();
console.log(date);

If you want it to look exactly like

00/00/0000 00:00:00

you can format it yourself using this:

var date = new Date();
console.log(date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());
obscure
  • 11,916
  • 2
  • 17
  • 36