Categories
JavaScript Answers

How to get datetime in JavaScript?

Spread the love

Sometimes, we want to get datetime in JavaScript.

In this article, we’ll look at how to get datetime in JavaScript.

How to get datetime in JavaScript?

To get datetime in JavaScript, we can use the Date constructor.

For instance, we write

new Date().toLocaleString()

to create a Date object and call toLocaleString on it to return a human readable string of the current date time formatted to the user’s current locale.

Conclusion

To get datetime in JavaScript, we can use the Date constructor.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *