March 7, 2012

Convert date string to date

Question by oshirowanen

I have a string Mar 7 2012.

How do I convert this to a Date object, so I can use mydate.getDate(), mydate.getMonth(), mydate.getFullYear() etc?

Answer by Starx

Well, Its pretty simple

var d =new Date("March 7 2012");
document.write(d.getMonth()); //use it

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!