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.