Skip to content
Advertisement

How to add Current Date and Time into Table?

how can I add the current date and time with this format: 2022-07-17 17:50:20?

I already managed it with an input value but I need the current time.

Advertisement

Answer

You should use built-in Date object in Javascript, like this:

JavaScript

By the way, I suggest you make all your vars into lets as that’s the current standard. There’s a very fine difference between them (let is block scoped while var is functional scoped).

Advertisement