APW APW - 3 months ago 30
Javascript Question

Converting Javascript String to Datetime

I have a text box that is populated from a datepicker in Javascript. The date is stored as

. I want to convert this to a date so I can use it in other calculations.

I have tried

var date1 = new Date(document.getElementById('textbox').value)

but this returns

if I drop the
new Date
part e.g.

var date1 = (document.getElementById('textbox').value

I get the date
I just don't seem to be able to convert this?


Looks like Date.parse is not going to work because the format the datepicker is returning.

You might want to look at the following thread for parsing solutions or change your format that the datepicker outputs to one of the supported formats.

How can I convert string to datetime with format specification in JavaScript?


Useful parse info: