Sometimes, we want to convert dd/mm/yyyy string into a JavaScript Date object.
In this article, we’ll look at how to convert dd/mm/yyyy string into a JavaScript Date object.
How to convert dd/mm/yyyy string into a JavaScript Date object?
To convert dd/mm/yyyy string into a JavaScript Date object, we can pass the string straight into the Date
constructor.
For instance, we write
const dateString = "10/23/2022";
const dateObject = new Date(dateString);
to create a Date
object from the dateString
string.
dateString
is in dd/mm/yyyy format.
Conclusion
To convert dd/mm/yyyy string into a JavaScript Date object, we can pass the string straight into the Date
constructor.