new Date().toLocaleDateString('en-US'); // "8/17/2018"new Date("8/17/2018") //valid date new Date(new Date().toLocaleDateString('en-US')) // Invalid DateI am trying to create date from local date
string (see screenshot) but its not working in IE11 only. It works with normal date string though.
I know something wrong with "" double quotes but not able to get it working.
Any suggestion ?

Seems it can be done like this
new Date(new Date().toLocaleDateString('en-US').replace(/[^ -~]/g,''))

Reference Answer
just use momentjs for this.
moment("8/17/2018", "L").format() would output:"2018-08-17T00:00:00+02:00"
(+02:00 is my local timezone. you can specify to use utc or another timezone too.)
also keep in mind L is dependent on the timezone profile you installed. this is the default en one.
you could also replace "L" with "MM/DD/YYYY"
the second argument of moment always specifies the format of your input.
it is also able to guess the input but you need to experiment with that.
.format("L") is essentially the same but in the output direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With