I am currently dealing with a situation where I need to convert a date format using the toLocaleString
method.
const localDate = proDate.toLocaleString("en-GB").replace(/,/g, "");
In this case, proDate
refers to a new Date(someDate)
object.
Later in my code, I face the challenge of converting localDate
back to the new Date()
format.
Although I attempted to use new Date(localDate)
, it resulted in an invalid date error.
The current format of localDate
is 18/03/2023 08:45:47
.
In my code, I do not have direct access to proDate
when trying to perform the conversion on localDate
.
Is there any alternate solution or workaround for this issue?