Categories
React Answers

How to get current date with React.js?

Spread the love

Sometimes, we want to get current date with React.js.

In this article, we’ll look at how to get current date with React.js.

How to get current date with React.js?

To get current date with React.js, we use the date’s toLocaleString method.

For instance, we write

const d = new Date().toLocaleString();

to create a date object and then call toLocaleString on it to return a string with the current date and time in the current locale.

Conclusion

To get current date with React.js, we use the date’s toLocaleString method.

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 *