Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  75] [ 1]  / answers: 1 / hits: 15162  / 12 Years ago, wed, january 30, 2013, 12:00:00

I have a text box that is populated from a datepicker in Javascript. The date is stored as 30-Jan-2013. 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 Nan



if I drop the new Date part e.g.



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


I get the date 30-Jan-2013 I just don't seem to be able to convert this?


More From » javascript

 Answers
12

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?



http://blog.dygraphs.com/2012/03/javascript-and-dates-what-mess.html



Useful parse info:



http://msdn.microsoft.com/en-us/library/ie/ff743760(v=vs.94).aspx


[#80514] Tuesday, January 29, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jensenb

Total Points: 634
Total Questions: 102
Total Answers: 102

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
;