How can I get current date and hour like this 2020-07-06T12:30:00.
in JavaScript / react
can you help me?
How can I get current date and hour like this 2020-07-06T12:30:00.
in JavaScript / react
can you help me?
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.
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}`)