0

Why following code is not work ?

var date = new Date("31/01/2015"); // => return "Invalid Date" alert(date); 

http://jsfiddle.net/fm3rnze5/

How can I get Date object from string ?

0

1 Answer 1

1
var date = new Date( Date.parse("2015/01/31") ); alert( date ); 

You need this format: YYYY/MM/DD. Then you can use Date.parse() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.