0

How can I get current date and hour like this 2020-07-06T12:30:00.

in JavaScript / react

can you help me?

Unmitigated
  • 76,500
  • 11
  • 62
  • 80
Paulo Rodrigues
  • 397
  • 4
  • 20
  • You can use appropriate date formators to achieve this. Its pretty easier just search for date formators – Deepak Jul 06 '20 at 20:20

4 Answers4

1

You can use new Date() to access the built in JS date, and to access it the way you are specifying you want the new Date().toJSON() which will give you "2020-07-06T20:25:23.671Z" for example.

James Begg
  • 132
  • 3
1

So you can use builtin Date object in JS.

const today = new Date()

let day = today.getDay()

let month = today.getMonth()

let year = today.getFullYear()

console.log(`${year}-${day}-${month}`)
0

You can use builtin Date object.

new Date();
0

You can use toJSON like

new Date().toJSON()
Rinkesh Golwala
  • 979
  • 1
  • 7
  • 17